coding-style

How many newlines should a Mono application use between "using" statements, and the namespace declaration?

I can't find anything about this in the Mono Project Coding Guidelines. Which is better: using Something; using SomethingElse; namespace SomeNameSpace { ... or using Something; using SomethingElse; namespace SomeNameSpace { ... I know it's not terrible important, but it can't hurt to do it right. The Mono guidelines ar...

Fixing indentation when object initializers have been used

Is there a tool that will auto-indent code that uses object initializers in the following manner: SomeType someType = new SomeType { Prop1 = "prop 1 value", Prop2 = "prop 2 value", Things = new List<Thing> { new Thing { ThingProp = "thing prop value" } } }; i.e. using the same br...

Is using underscore suffix for members beneficial?

class C { private: int member_; // here is the underscore I refer to. } This underscore is recommended by Google Style Guide and Geosoft's C++ Style Guide. I understand that there are different opinions and tastes. I want to ask people who used it or were forced to use it whether they found it beneficial, neutral or harmful for th...

Is using labels in Perl subroutines considered a bad practice?

I find that using labels inside Perl subroutines, to break from multiple loops, or to redo some parts with updated variables, very helpful. How is this coding style seen by the community? Is using labels inside subroutines frowned upon? ...

Should I use comments in code, liberally?

All, To comment liberally or not to?? Pros and Cons. I personally prefer commenting as it leaves nothing to the fancies of the people reading it. Thanks ...

C Code layout and how to separate different sections of code?

In a C code, how you separate different sections of code, for example Implementation, Globals, etc? Is there a coding standard. I have seen many methods, but which one is preferred, I want to get community opinions on this.. /********************************************************* * GLOBALS ...

Which is better coding style?

During a code review, a senior dev commented on some nesting I had going on in my code. He suggested I set a bool value so that I never have more than one level of nesting. I think my code is more readable but want to get other devs' opinion on this. Which is better style? Is his knee-jerk aversion to nesting founded? Below are some...

Is this a better (more functional way) to write the following fsharp code?

Hi, I have pieces of code like this in a project and I realize it's not written in a functional way: let data = Array.zeroCreate(3 + (int)firmwareVersions.Count * 27) data.[0] <- 0x09uy //drcode data.[1..2] <- firmwareVersionBytes //Number of firmware versions let mutable index = 0 let loops ...

Microsoft Coding Standard Document

Is There a Coding Standard document available for download from Microsoft ? I want to use their standards. ...

2nd or 3rd person comments?

Do you write comments in 2nd or 3rd person? // go somewhere and do something (2nd person comment) or // goes somewhere and does something (3rd person comment) ...

Why is it preferable to write func( const Class &value )?

Why would one use func( const Class &value ) rather than just func( Class value )? Surely modern compilers will do the most efficient thing using either syntax. Is this still necessary or just a hold over from the days of non-optimizing compilers? Just to add, gcc will produce similar assembler code output for either syntax. Perhaps...

Is there a standard for code margins?

Similar Questions While coding, how many columns do you format for? What is a sensible maximum number of characters per line of code? Do people still live by the 80 column rule? The 80 column limit, still useful? By code margins I am referring to the lines that guide how long a particular line of code is. Different IDEs hav...

What is the correct way to convert from a for loop to a while loop?

I have a for loop of the form: for (int i = from; i < to; i++) { // do some code (I don't know exactly what, it is subject to change) } And I want to convert it to a while loop (mostly because I want to play with the value of i inside the loop to go backwards and forwards and my co-worker thinks that doing this in a for loop is pron...

Best practice for function flow in Javascript?

I have what I thought was a relatively easy Ajax/animation that I'm adding to a client site to select between projects for display as images. The flow goes something like this: User clicks on a thumbnail in a project overview (pHome). Using jQuery, ajax load in an XML file with the image, caption and project description data (project1...

Is there a good alternative to xml documentation comments for C#?

I find the xml doc comments for C# or VB.NET very hard to read. Is there a decent alternative (that still provides the benefits of documenting code for intellisense, doc generation, etc.)? ...

PHP IF statement for Boolean values: $var === true vs $var

I know this question is not really important.. however I've been wondering: Which of the following IF statements is the best and fastest to use? <?php $variable = true; if($variable === true) { //Something } if($variable) { // Something } ?> I know === is to match exactly the boolean value. However is there really any im...

Arguments Against Annotations

My team is moving to Spring 3.0 and there are some people who want to start moving everything into Annotations. I just get a really bad feeling in my gut (code smell?) when I see a class that has methods like this: (just an example - not all real annotations) @Transaction @Method("GET") @PathElement("time") @PathElement("date") @Autowi...

What style of programming is this called?

I don't have good name for this style of programming where the syntax is more succinct because of not having to pass the context into a function or call the functions off of a context object. For example, some random OpenGL C code: glBegin(GL_QUADS); glNormal3fv(&n[i][0]); glVertex3fv(&v[faces[i][0]][0]); glVertex3fv(&v[faces[i][1...

Hyphens or underscores in CSS and HTML identifiers?

As both hyphen (-) and underscore (_) are valid characters in CSS and HTML identifiers, what are the advantages and disadvantages using one or the other? I prefer writing CSS class names with hyphens (e.g. field-text) and underscores for IDs (e.g. featured_content). Is there a best practice or it's only the matter of taste? ...

Instance variable naming conventions in Cocoa

This question is about variable naming style in objective c and cocoa. I just want to stress that I'm not looking for a "right" answer, just good ideas. I've read through Apple and Google's objective c style guides and I'm not really happy with either of them. Apple's guide doesn't have any real style recommendations regarding instanc...