This question exists because it has historical significance, but it is not considered a good, on-topic question for this site, so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. More info: help center.

closed as not constructive by Mark Trapp Sep 26 '11 at 8:19

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
If this question can be reworded to fit the rules in the help center, please edit the question.

The real problem with coding standards is the time and effort wasted arguing over whether they are correct or not. Nothing beats a good curly-brace war for creating internecine strife...
–
MZBOct 14 '10 at 16:07

@Joe D. Yeah, because I, a lowly developer, can change the coding standard for a company that employs 3,000+ other developers.
–
µBioSep 30 '10 at 16:37

2

@configurator it's not a matter of whether I consider myself lowly or not. I check in code out of coding standard format, it doesn't go to trunk. Period. And so my tasks don't get complete. Who looks bad, the engineers who define the standards for the entire industry, or me, who didn't complete my task?
–
µBioOct 1 '10 at 22:18

1

With repesect to the second part of your answer: The class prefix is the really bad one. I'm indifferent about the _t for typedefs, since the C standard library (and thus much of the C++ standard library) uses that convention, and I can see some value in going with the language's standard convention. I'm not really a fan of the enum prefix, but can see some tiny value in it as a reminder that it is only a thin wrapper over an integer, and may have invalid values.
–
Kevin CathcartApr 23 '12 at 18:37

Nearly any sort of variable naming convention that reiterates the variable type, mutability, scope / storage class, and/or their reference. Basically, any construct intrinsic to the language. This is no longer necessary in the 21st century with modern IDEs (and in my opinion only originally solved poor code layout / practices to begin with). This includes hungarian notation and its variants:

bigBlobStr - A string.

bigBlobStrCurLocPtr - A pointer to the "current location" in said string.

someIntArray - Array of integers

or things like:

e_globalHeading - External variable

sg_prefPoolSz - Static global variable

and of course one the farthest reaching eyesore in OOP, m_ for all members. If you can't be sure / keep track of which variables are local, members, globals, static, or final/const, you might be writing unclear, poorly factored, spaghetti code.

This is wholey different than specifying a prefix/suffix convention for things like min, max, avg, size, count, index, et cetera, which is fine.

Sometimes there are good reasons for including type information in variable names.
–
finnwSep 14 '10 at 2:09

3

Umm... interesting that you quote Spolsky's article on it, as it's more to the point, "The dark side took over Hungarian Notation." It's all about "Apps Hungarian" being twisted into "Systems Hungarian" because people make an incorrect inference about what Simonyi meant when he said "type". It's to see wrongness when you are assigning a "colX" to a "rowY", not so that you can keep track of the fact that something is a long integer as opposed to a short. Also, I specifically call out only variables. I foresee a -1 from swaths embedded devs still using vi and C++ devs as it's "just the way".
–
charstarSep 14 '10 at 6:18

Take every pointless standard ever and put it into a tool that runs at compile time instead of in the IDE at design time.

//this is not a legal comment.
// nor is this

// must be followed by a single space, if you are debugging, use //// to comment code.
Properties must also have 'triple slash' comments and they must read "Gets or Sets xxxxx" complete with a period at the end and properly capitalized.

Ugh. Maybe there's a point with widely published APIs but my main beef is they surely could have built it as a plugin a la R#.

At a previous job, the C# standard was to have at least two spaces between type name and variable name in declarations, the method name must begin on the next line from the access modifiers and return type, a space must occur before any open-punctuation (parenthesis or bracket), all variable declarations at the beginning of the method, declarations separate from assignment and the indentation was 3 spaces. Example:

Some of these you can configure in VS options (like the space before the parentheses), but not the double spacing. That doesn't make enough sense to be configurable.
–
Kirk BroadhurstSep 24 '10 at 1:32

1

I've come to the conclusion people using C# need to realize IT IS NOT VB6. You can set variables on the same line as declaration. You don't need Hungarian Notation. You don't need this "m_" crap for member-level variables. I swear, most of my frustration with C# comes from people who still think in the old Classic VB mentality. I'm mad, bros.
–
Wayne MJun 2 '11 at 16:00

Fields had to be prefixed: DS_ (for
varchar, which made no sense) NU_ for
numbers CD_ for ("bit fields") DT_
for dates

database fields had also to be uppercase [CD_ENABLED]

same with sp names [SP_INFINITY_USER_GROUPS_QRY] and database names [INFINITY]

did I mention sp names were actually like that? SP_ prefix, then database name SP_INFINITY_ then table name, SP_INFINITY_USER_GROUPS then what the sp was actually expected to do (QRY,UPD,DEL,INS) jesus, don't even get me started on queries that weren't just CRUD queries.

all text fields had to be varchar(MAX), unequivocally.

numbers were either int or double, even when you could have used other type.

"boolean" fields (bit) were int, no reason.

stored procedures had to be prefixed sp_productname_

asp.net / c# / javascript

EVERY single function had to be wrapped in try{}catch{}, so the applications wouldn't "explode" (at least that was the official reason), even when this produced things not working and not having a clue why.

parameters must be prefixed with p, e.g pCount, pPage

scope variables had to be prefixed with w (as in "working", what the hell does that even mean?)

statics with g, etc.

everything post framework 1.1 was offlimits, like you had any real uses for linq and generics anyways. (I made it a point to enforce them to let me use jquery though, I succeded at that, at least).

While this may still have a small value if there is risk of needing to port your program to an obsolete compiler, it's mostly just a hassle. My biggest objection is that it makes it really hard to use /* to block comment out a large region during development or unit testing. */

A professor at my university who I was fortunate enough not to have insisted that her junior C# students not be allowed to put more than one line of code in their console applications' entry point.

This makes a reasonable amount of sense when developing a professional application, but when the program's only intent is to take few basic inputs and produce a single output (i.e. MultiplyTwoNumbers.exe), such a requirement is more pain than good.

On top of the "one line of code in main" the professor also insisted that every line of code have a descriptive comment and every class member have a verbosely descriptive name. Points lost if the professor didn't feel that these requirements had been met "adequately".

The students forced to stick to these rules were (almost) all newbies to programming and thus I can see the value of enforcing conducts like good-naming and separation of concerns. Despite that, as the .NET Tutor at my university I was constantly helping her students meet these mundane and obnoxious requirements long after they had gotten their code working.

In my opinion, when educating someone who is brand new to a programming language the first concern should be how to create code, not how to create standards-based code.

Where I'm working now the variable naming process for anything dealing with the database is:

$sql for statements

$result for query results

Which makes sense, however when I brought up the point that the convention was too generic and that this would end up with variable overlap the response was "use result_alt or sql_alt." My feelings on commenting, if you used proper variable names that signify purpose you wouldn't need comments or as many of them.

Interfaces exist for some good reasons, but this standard mandated an interface (foo.java) for every single class (fooImpl.java) whether it made any sense or not. Lots of stuff to keep in sync, complete disruption of Eclipse click-into-method, pointless busy-work.

The build system enforced it, but I cannot imagine what the original purpose was. Fortunately we ditched it for new code when we switched to a new version-control and build system, but there's still a lot of it about.

At the same time we also ditched the stupid version-control-info-in-file-comments habit which had been mandatory.

+1 to rally against the belief that every class someone writes might some day be part of an far-reaching public API of global importance and therefore needs a rigid interface separate to its implementation... as if it's destined for the IETF or something. Most of time I see "Impl", it makes my blood pressure go up because this tells me you didn't write the interface to specify class compliance (good), you did it to because "everything is a framework" (bad+wrong).
–
charstarSep 13 '10 at 23:00

1

"Find Implementing Methods" is all very well, but it's not much help when you see foo.frobnosticateWith(bar);, ctrl-click on frobnosticateWith, and find yourself at the interface definition of the method rather than the implementation you wanted to see. It's fine when interfaces are being used for good, and maybe there are (or could be) multiple implementations, but this is not the case here.
–
user763Oct 5 '10 at 16:28

The worst coding standard I ever had to follow was "All object variable names must be prefixed with 'obj'". This was on a big Java project, so almost everything was an object. The worst part was, almost everyone adopted a policy of naming variables by simply prepending "obj" to the class name. We wound up with stuff like Person objPerson1 throughout the code. I objected once, and had one of the other developers interject that she liked the convention "because then I don't have to think about my variable names". That place was a real horrorshow...

Writing anything in Fortran (WATFOR, FORTRAN 77) where a non-whitespace character in column 1 was a comment, and the compiler didn't warn you if you went beyond column 72, it would just silently ignore it.

My favorite would have to be the database naming guidelines we currently are trying to abide by. All tables used for many-many relationships should be named using the names of the linked tables and must be suffixed with "Link". And of course, no pluralization of table names.

My ADA lecturer at uni insisted that every method had a comment outlining preconditions, postconditions and big O. The biggest issue with this was that he never bothered to explain what big O actually meant and never checked if they were correct so I found myself copying and pasting this comment block hundreds of times.

Limited space for variable/object names is probably my largest irritation. I've worked in a relatively modern, proprietary language that only allows 10 characters. This is a holdover from its original versions.

The net result is that you end up with funny naming conventions defining what each character of your allowed 10 is to represent. Something like:

80 column limit - considering we're all using widescreen monitors these days is just wasting the limited vertical space we don't have, and not making use of the horizontal space we do have.

Tabs for spaces - perfect way to make your code look like a mess when opened in different editors which have different tab sizes. (Also, eight space tabs is just wasting the very limited 80-columns you have to work with anyway).

Inconsistent brace positioning, for what reason? What's wrong with 1TBS?

There are a number of other guidelines there which are just "good practices", without reasoning.

There is good readability reasons for limiting the width of text, but should be a guideline to avoid indefinitely long lines rather than a hard limit.
–
RichardSep 9 '10 at 7:09

4

I prefer tabs over spaces just so that, if my co-worker likes 2 space indentation and I prefer 4, we can just set our editors to be different.
–
Ben DoomSep 9 '10 at 18:22

5

Am I the only person who likes 80 column limits because that way I can have multiple files open side by side, and so side-by-side diffs can be displayed without line wrapping?
–
nohatSep 10 '10 at 2:11

2

If your using tabs, you don't have to make them 8 spaces.
–
alternativeSep 10 '10 at 22:27