coding-style

Generate Coding guidelines from CheckStyle

岁酱吖の 提交于 2019-12-05 08:19:04
Is there a way to generate a 'nice' Coding conventions / guidelines document from existing CheckStyle configuration file? This document must contain the description of the rules enforced, and the configuration values (like the max line length, violation severity, etc). The benefit of having such a document is to ramp up a new team member faster, without reading CheckStyle configuration file. I would generally advise against generating even parts of a coding guidelines document, because that would cause acceptance problems with your software engineers. Also, the Checkstyle rules should, in my

Tools for upper/lower case consistency in CMake source

微笑、不失礼 提交于 2019-12-05 07:57:20
CMake commands are valid in lower, upper, and mixed case. Mixing all of those together in one file however reduces the readability of the CMake code. Is there a tool for automatically correcting this kind of stylistic inconsistencies? The answer by steveire links to the right resources, but let me explain explicitly in case those links vanish. CMake command are case insensitive but lower case is recommended according to CMake developer Brad King in 2012: Ancient CMake versions required upper-case commands. Later command names became case-insensitive. Now the preferred style is lower-case. The

String.Format or Not? [duplicate]

岁酱吖の 提交于 2019-12-05 07:54:10
This question already has answers here : Closed 10 years ago . Duplicate from : String output: format or concat in C#? Especially in C# world using String.Format for everything is really common, normally as VB.NET developer unless I have to* I don't String.Format, I prefer normal string concatenation, such as: V1 = V2 & "test-x" & V3 & "-;" to me it's better than this: V1 = String.Format("{0} test-x {1} -;", V2, V3) Am I missing something? Or is this just a personal preference? Reasons to Use String.Format (From The Answers) ( I'll try to keep this up to date ) Localization is so much easier

Naming convention for posix flags

送分小仙女□ 提交于 2019-12-05 07:28:43
问题 I'm writing a console application which allows several Posix flags to be set. This is what I'm using currently. Words in the flags are concatenated with a dash: -p, --broker-port int Broker Port (default 1883) -u, --broker-url string Broker URL (default "localhost") -c, --client-id string MQTT Client Id -r, --room string Room where sensor is located (default "myroom") -f, --floor string Floor, where room is located (default "basement") However I have also seen applications using CamelCase to

When to use which - multiple methods, multiple parameters, or an options parameter

天大地大妈咪最大 提交于 2019-12-05 07:27:04
This question is coming from a javascript point of view, but it certainly could apply to other languages. I have been running into this more and more lately, and was wondering if there was a best practice, or at least good design standard, for when how to build your methods. The obvious options that I see are as follows, along with a trivial example for each Multiple methods: this.makeGetRequest = function(controller){...} this.makeSynchronousGetRequest = function(controller){...} this.makePostRequest = function(controller, data){...} One method, with more parameters: //data would be an

How do you change the textcolor of the list items in an AlertDialog

扶醉桌前 提交于 2019-12-05 07:20:18
Hello I am trying to change the text color of the items in a list on a ListPreference pop up window. I have spent over an hour looking through all of the various style names but I can't find TextAppearance or anything that goes to this particular text. Thanks for your help! You can't and you shouldn't. *Preference uses styles from com.android.internal.R.styleable which might be changed by manufactures. The idea of using the default ones is that every preference screen in your device look alike. On the other hand you can try doing an Activity with android:theme="@android:style/Theme.Dialog" in

JavaScript code conventions - variable declaration [closed]

孤街浪徒 提交于 2019-12-05 06:52:53
What's the less error prone approach to declare variables in JavaScript? var a; var b; var c; or var a, b, c; jQuery and Dojo use the second approach and personally that's my favorite in terms of code legibility, the problem is that I find it harder to debug. Example 1: var a, b, c; // oops.. semicolon instead of comma d, e; Example 2: When searching for a certain variable in the project, var stands out better that the variable is being declared. EDIT : The original examples were wrong, i've made a mistake when copying and pasting. The code is already updated, sorry for the incovenient.

Safest way to change variable names in a project

喜夏-厌秋 提交于 2019-12-05 06:23:42
So I've been working on a relatively large project by myself, and I've come to realise that some of the variable names earlier on were.. less than ideal. But how does one change variable names in a project easily? Is there such a tool that can go through a project directory, parse all the files, and then replace the variable names to the desired one? It has to be smart enough to understand the language I imagine. I was thinking of using regexp (sed/awk on linux?) tools to just replace the variable name, but there were many times where my particular variable is also included as a part of

Bind a char to an enum type

大城市里の小女人 提交于 2019-12-05 05:46:39
I have a piece of code pretty similar to this: class someclass { public: enum Section{START,MID,END}; vector<Section> Full; void ex(){ for(int i=0;i<Full.size();i++) { switch (Full[i]) { case START : cout<<"S"; break; case MID : cout<<"M"; break; case END: cout<<"E"; break; } } } }; Now imagine I have much more enum types and their names are longer.... well what i get is not a very good looking code and i was wondering if it possible to bind a specific char to an enum type and maybe do something like this: for(int i=0;i<Full.size();i++) { cout<(Full[i]).MyChar(); } Or any other method that

Variable declaration placement guidelines in Java [closed]

烂漫一生 提交于 2019-12-05 05:30:04
Closed. This question is off-topic . It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 8 years ago . There seems to be two accepted variable declaration placements for Java variables, each with different raison d'être . From the Sun's code conventions we can see: Put declarations only at the beginning of blocks. (A block is any code surrounded by curly braces "{" and "}".) Don't wait to declare variables until their first use; it can confuse the unwary programmer and hamper code portability within the scope.