What was the strangest coding standard rule that you were forced to follow? [closed]
Asked Answered
C

112

173

When I asked this question I got almost always a definite yes you should have coding standards.

What was the strangest coding standard rule that you were ever forced to follow?

And by strangest I mean funniest, or worst, or just plain odd.

In each answer, please mention which language, what your team size was, and which ill effects it caused you and your team.

Carnify answered 20/10, 2008 at 11:38 Comment(1)
After reading thru this list suddenly I feel like I've had a very lucky career to avoid any of this forced standard crap!Foam
D
433

I hate it when the use of multiple returns is banned.

Dyeing answered 20/10, 2008 at 11:38 Comment(29)
What is the supposed point of this rule? Personally I'd fail a code review for code that could be made easier to read by putting in another return.Costrel
From my experience, methods with one single return point tend to be less error prone, as that rule makes it easier for people to analyse the program execution.Puga
On the other hand, eliminating an option at the beginning like "if(param == null) return null" can clean up your code quite a bit, to prohibit this instead of encourage it is somewhat criminal.Weitman
I think multiple returns are fine up until a certain complexity and that's how it should remain a judgment call on code clarity like alwaysTavel
Workaround: if (!Initialize()) { RetVal=ERR_BADINIT; goto ReturnPoint; } (lots more code) ReturnPoint: return RetVal; } Problem solved! ;)Nga
Up until recently, multiple returns were banned. Then the fact this was a leftover from C, rendered obsolete by C++ RAII and functions with size less than 15 lines, was revealed. Since then, like Braveheart: "FREEDOM !!!!" ... :-p ...Perusse
Using one exit point should be encouraged, but certainly NOT being enforced. Especially if you consider early-out conditions.Matsumoto
The main reason for having one return point is to simplify testing of execution paths. Returns to shortcut execution can be misused. Even a single return inside a loop dramatically increases the test surface. It's easier to simply say 'one return point' without knowing why.Illuminating
Simply put multiple returns increase testing complexity. Further it increases the likelihood that you've done something wrongPotentate
The real rule is that you should always return where you came from (instead of GOTOing). It doesn't matter how many returns you have as long as they're returns. This ban rule is a fundamental misunderstanding from people who apparently think they're programming in BASIC.Agnesse
multiple returns (except for an initial error check) are the sign of poor programming and made code very complicated very quickly.Owenowena
I don't like multiple returns either. I think it usually shows that your method is probably doing too much. However, I wouldn't dream of a totally banning it. WTF? If you distrust 'your' devs that much, hire new ones.Hippomenes
I think the real problem is a case of throwing the baby out with the bathwater. Early returns from bailouts are a good thing and it's sometimes quite reasonable to end a routine with a conditional where the paths simply are returns. Most any other case should be avoided.Huttan
Hard and fast rules like this break my heart. Sometimes it makes sense, sometimes it doesn't. If it doesn't don't use it. While I have preferences I don't BAN anything. If I need to use "goto" I'll use it . . . it's just so far I haven't needed it (thank Jebus).Tintometer
Your choice: multiple returns or more nested if statements. I'll take multiple returns.Shantishantung
I think discouraging multiple returns is a reasonable principle but, like others say, the nesting can get horrific if you ban it completely.Egestion
For most functions I think it's appropiate to once you have decided further execution of a function is impossible, you return/signal error. Makes the rest of the function less nested and easier to follow. It's like pre-conditions.Supramolecular
Bah! this is nonsense up with which I will not put! Multiple return statements can be elegant. How would you do a nice switch..case blocks without them? Multiple breaks instead? They're not all that different than return statements.Riding
@Riding - Agree 100%, if you can bail out early of a function that does heavy lifting, why not give your program that extra bit of efficiency? multiple returns allows this...Nunhood
Given the choice I would ususally prefer to litter my code with dozens if not hundreds of "if retcode" than return early especially when synchronization objects, memory or network connections are invovled. An outright ban is stupid but if it prevents people from committing even dumber mistakes WRT resource management than so be it. I can give a crap less about overhead, thats what the CPUs branch cache is for. Quality is much more important than either developer comfort or a few extra CPU cycles.Basically
Assuming that the single return version handles the same inputs, then testing won't be significantly easier. You still need to see that the function handles NULL, after all; you just happen to know that the function doesn't use an extra return to do so.Readymade
I've seen this before. Generally the argument is that blocks should have "only one exit point". However, blocks do have only one exit point, unless you use gotos or exceptions. They might have more than one path to get to that point, but if you don't like that you need to ban "if" and "for" statements as well.Flagitious
This one is simple. Multiple returns => good choice for small functions, bad choice for gigantic ones. So - it's more about writing gigantic procedural code. That's the real cause what should be banned.Shinberg
For all those trying to figure this out : it is a micro-optimization intended to increase speed slightly due to NRVO; like all micro-optimizations, it should not be used except at extreme bottlenecks. See the second half of #37207Carbarn
Does this imply it's forbidden to throw exceptions too? Throwing an exception can also be seen as a return point...Bartizan
Doesn't recursion require at least two returns? Are they are banning recursion?Bohs
I don't understand where this pro / anti multiple returns thing has come from - its a completely arbitrary choice (my preference is with a single return statement)Molini
If you want to debate this issue, don't comment here - go over to "Should a function have only one return statement?" #37207Constitutionality
@AsLanFromNarnia: Recursion requires at least two branches, not two returns. You can always have a local variable to store the return value and have one return statement at the end.Faus
B
333

reverse indentation. For example:

    for(int i = 0; i < 10; i++)
        {
myFunc();
        }

and:

    if(something)
        {
// do A
        }
    else
        {
// do B
    }
Byer answered 20/10, 2008 at 11:38 Comment(10)
Oh my god ... Can I meet the sociopath who came up with that one? He could teach me a thing or two about misanthropy.Subcritical
Every time you reverse the indentation, God kills a maintenance developer.Riebling
The second one is the Gnu style for C. So no, it is not a joke: gnu.org/prep/standards/standards.html#FormattingYawmeter
My first instinct when I saw this was to edit it to correct the indentation... until I realized that the indentation was actually intentional...Mahla
@David Cournapeau: I didn't find any place in the GNU coding standard you linked to where reverse indentation was advocated -- the example I saw uses normal indentation. You realize that whatever code replaces // do A in this example would appear at the zero-th indendation level (i.e. no spaces or tabs to the left of it)?Mahla
No, the second example is not GNU. What connects it to GNU style though is the weird belief that spaces before opening braces on new-lines are a good thing.Treva
I use reverse indentation whenever switching between languages. For example javascript or CSS inline with HTML, I reset the indentation on language change. Same for PHP blocks in HTML.Grayson
I use reverse idention for the #if of a C# Preprocessor Directive.Trepang
So say if you add a new if-statement somewhere on the deepest level, you will need to indent the whole code around it? Is this an Arab thing, since they write from left to right? LOLBartizan
In some cases, when I really want something to stick out, I'll reset the indentation to zero. That means some comments, and #if directives (Also, because that's how vim auto-formats them...).Bilingual
U
325

Maybe not the most outlandish one you'll get, but I really really hate when I have to preface database table names with 'tbl'

Unearth answered 20/10, 2008 at 11:38 Comment(13)
Isn't this just hungarian notation for DB's?Parhelion
Isn't that like prefixing variables with var?Carnify
If remember correctly one of the very few keyboard shortcuts sql server had was to type the first letter of the table name to get to that table in the list; the first AND ONLY THE FIRST letterDisembroil
"Systems" Hungarian to be precise.Pinchbeck
In a similar vein, I hate when ID columns in databases are prefixed with the table name, like in the product table there'd be a productid column. Redundancy that sometimes makes scripting without an ORM more of a headache than it needs to beStaffer
I actually prefer the ID column to be prefixed with the table name. Makes writing queries a bit easier. And for foreign keys you can have the foreign key field the same as the key field.Hewett
I guess when refering to generic database objects, seeing a "tbl" prefix can immediately identify as a table instead of querying for its actual object type in a system table. BUT, who does that kind of low-level database operation anyway? ;-)Megrim
You might get the table confused though! With a girraffe.Rebbecarebbecca
On a similar note, I hate it when table names must be singular. My instinct is to name a table that holds, say, customers, "Customers", not "Customer". Sounds minor, till you realize all the trouble you would save if only you could name your table "Transactions" instead of "[Transaction]".Steric
I like when the ID columns for all tables are called RecordID this way it makes everything very consistent. Its my preference but when you write a query with joins there is no need to look up columns to see what the names are.Canonicals
how about prefixing column names with the table name... CUSTOMER.CUSTOMER_REFID... now imagine the references to other tablesEggleston
how about prefixing stored procedures with 'pra'Assets
I do databases all day every day and I definitely prefer that the id column of each table contain the table name as part of the column name (eg "productid" instead of "id). I find it makes even moderately complex queries easier to read and gives a more usable set of default column names in the result set.Mahdi
W
247

Almost any kind of hungarian notation.

The problem with hungarian notation is that it is very often misunderstood. The original idea was to prefix the variable so that the meaning was clear. For example:

int appCount = 0; // Number of apples.
int pearCount = 0; // Number of pears.

But most people use it to determine the type.

int iAppleCount = 0; // Number of apples.
int iPearCount = 0;  // Number of pears.

This is confusing, because although both numbers are integers, everybody knows, you can't compare apples with pears.

Weiland answered 20/10, 2008 at 11:38 Comment(13)
See this Joel on Software post about how proper use of Hungarian notation can help reduce bugs: joelonsoftware.com/articles/Wrong.htmlTortile
Of course by using C++ instead of C you can write code so that the compiler gives you an error when comparing apples to pears.Impossibly
Hungarian notation is still valuable for languages which don't enforce types - JavaScript is the big one.Alcaraz
True, but you can better focus on the real world type not the system type.Weiland
Shouldn't that be "int cntApples = 0; int cntPeas = 0;"? Ie. The prefix is the variable "kind".Uproar
No, else you are "allowed" to compare them together. Although you have a point on that the prefix should include both fruit type and count so appcntInMyBasket is probably better.Weiland
I read a story that hungarian notation was originally used to tell whether a variable contained validated data. uInput was unchecked user input, sInput contained checked input. This use is actually very useful.Caryloncaryn
Shouldn't that be "Number of peas"?Hawkshaw
App hungarian would name these variables cApple and cPear, for "count of apples; count of pears"Energid
@chryss: No, it's not a typo. "app" and "pea" are intended to mark the count variables to be of the type/kind "apple" or "pear". That was the original intention of the original (=good) hungarion notation.Vaporimeter
At least the first one is correct ... everything with "Apple" in it needs to be prefixed with "i". ;)Carin
The way you are using Hungarian makes very little sense to me. SEe, you CAN add the number of apples you have to the number of peas you have to end up with the number of apples and peas you have.Uganda
The microsoft coders who wrote the Win16/Win32 API and SDK popularized this hungarian-is-for-c-typing-info approach, which is SO wrong to make a general coding standard.Smalley
S
239

To NEVER remove any code when making changes. We were told to comment all changes. Bear in mind we use source control. This policy didn't last long because developers were in an uproar about it and how it would make the code unreadable.

Selfwinding answered 20/10, 2008 at 11:38 Comment(4)
Rules like that are why I feel a NEED to print source code I inherit from others in color. At a dime a page, that's not very nice to my company -- but it's the only way I can read it if I have to print it. (We've inherited a lot which followed this rule ... )Subcritical
Sounds like a rule developed pre source control. Or due to programmers only checking in once a week.Hewett
I've done this on maintainence projects without source control, then remove all the comments after it passed validation testing. But now, I'd have to be in a real bind before I'd work without source control! This isn't 1995 anymore!Preconcerted
Some places WORK without source control?Behka
A
239

No ternary operator allowed where I currently work:

int value = (a < b) ? a : b;

... because not everyone "gets it". If you told me, "Don't use it because we've had to rewrite them when the structures get too complicated" (nested ternary operators, anyone?), then I'd understand. But when you tell me that some developers don't understand them... um... Sure.

Adis answered 20/10, 2008 at 11:38 Comment(14)
By everyone, your boss means himself.Carnify
I actually had a a coworker that was really opposed to the ternary operator because "it hides expensive comparisons". When comparisons are a bottleneck, start thinking about changing your approach to the problem...Regulation
I used to fall into this camp ... But grew out of it, and have learned to love the conditional operator (when it's appropriate).Subcritical
Note that some compilers are brooooken when dealing with ?: on C++ objects... Sun's Studio 8 compiler certainly had a couple of different problems with ?: in that scenario, where things could get destroyed twice or constructed wrong. So if you're going to use ?: on objects, test it!Penthouse
If anything, the rule should be "always use the ternary operator", an operator of pure beauty :)Effendi
This is exactly what I was going to say--had it happen to me at my first C job. On the other hand, if you are using it in a situation where someone might have to take an extra 5 seconds to read it over an if statement, skip it. Readability is all that matters.Weitman
I used to hate the ternary but now i love it, but still use it sparsely. But it's just too great for debugging code because you can put something like this in the assert or log parameters without bloating the code: Log("{0}", (obj != null) ? obj.ToString() : "<null>");Matsumoto
I love it, but the reason I get most often for not using is is the same as your experience "people wont understand it". My argument is that they shouldn't be working if they can't understand the concept...Swordplay
I have actually experienced being forced to use it because some code generator only allowed expressions in its inputs, and if is a statement.Riebling
Tell your boss to look at the source of Scheme48.Sigma
How else would you conditionally initialize a constant variable without writing a whole new function (which won't do much good for readability). The use of const for local "variables" does much more good for understanding and following the code than a ban of the ternary operator.Impossibly
Personally I hate it as well, since its less readable than a plain old if statement. And Andreas, writing a whole new function is just fine if you name it right.Shorthanded
Personally, I can't stand reading code that uses the ternary operator. It just kills the readability for me.Stollings
I dont mind it as long as its kept simple. The job-security kind of guys or the guys who love to write fancy unreadable code who make a ternary that looks like a single line of 256 bit crypto.. should not be allowed to use them.Readily
P
204

I once worked under the tyranny of the Mighty VB King.

The VB King was the pure master of MS Excel and VBA, as well as databases (Hence his surname : He played with Excel while the developers worked with compilers, and challenging him on databases could have detrimental effects on your career...).

Of course, his immense skills gave him an unique vision of development problems and project management solutions: While not exactly coding standards in the strictest sense, the VB King regularly had new ideas about "coding standards" and "best practices" he tried (and oftentimes succeeded) to impose on us. For example:

  • All C/C++ arrays shall start at index 1, instead of 0. Indeed, the use of 0 as first index of an array is obsolete, and has been superseded by Visual Basic 6's insightful array index management.

  • All functions shall return an error code: There are no exceptions in VB6, so why would we need them at all? (i.e. in C++)

  • Since "All functions shall return an error code" is not practical for functions returning meaningful types, all functions shall have an error code as first [in/out] parameter.

  • All our code will check the error codes (this led to the worst case of VBScript if-indentation I ever saw in my career... Of course, as the "else" clauses were never handled, no error was actually found until too late).

  • Since we're working with C++/COM, starting this very day, we will code all our DOM utility functions in Visual Basic.

  • ASP 115 errors are evil. For this reason, we will use On Error Resume Next in our VBScript/ASP code to avoid them.

  • XSL-T is an object oriented language. Use inheritance to resolve your problems (dumb surprise almost broke my jaw open this one day).

  • Exceptions are not used, and thus should be removed. For this reason, we will uncheck the checkbox asking for destructor call in case of exception unwinding (it took days for an expert to find the cause of all those memory leaks, and he almost went berserk when he found out they had willingly ignored (and hidden) his technical note about checking the option again, sent handfuls of weeks before).

  • catch all exceptions in the COM interface of our COM modules, and dispose them silently (this way, instead of crashing, a module would only appear to be faster... Shiny!... As we used the über error handling described above, it even took us some time to understand what was really happening... You can't have both speed and correct results, can you?).

  • Starting today, our code base will split into four branches. We will manage their synchronization and integrate all bug corrections/evolutions by hand.

All but the C/C++ arrays, VB DOM utility functions and XSL-T as OOP language were implemented despite our protests. Of course, over the time, some were discovered, ahem, broken, and abandoned altogether.

Of course, the VB King credibility never suffered for that: Among the higher management, he remained a "top gun" technical expert...

This produced some amusing side effects, as you can see by following the link What is the best comment in source code you have ever encountered?

Perusse answered 20/10, 2008 at 11:38 Comment(8)
Re: 1-indexing. Sometimes you just have to stand up and say something strong like "that's stupid and wrong". Draw a line in the sand. Forget placating egos and just say it. I can almost guarantee that every other worthwhile programmer will immediately start nodding and joining in.Commandment
Of the 10 points I mentionned, 7 points were implemented despite protests. The C/C++ array at 1, the DOM in VB and the XSL-T language as a OOP language were either refused (1 and 2) or simply irrealistic (2). I mentionned all the points to show how deep the VB King madness/stupidity went... :-p ...Perusse
Need I point out that in all version of Basic (including VBA & VB6), arrays actually do start at 0?Easy
For completeness sakes, yes, you need... :-p ... The fact is my Basic days were well over (I played with QBasic before moving to C) at the time the proposition was considered... I was unaware the OPTION BASE default was zero in VB, and the VB-King never mentioned it (did he even know it?)... :-p ..Perusse
@jrista: If YOU ARE NOT commenting the spelling of my text, please ignore the following ... ... ... ... ... ... ... ... If you are commenting my text, please consider (1) proposing corrections, (2) correcting the spelling yourself, or (3) Consider that not every developer in the world (far from it) are native english speaker, so I guess tolerating incorrect spelling is the minimum you can do, or prove you can do better by sending me the correct translation IN FRENCH... ^_^ ...Perusse
If this guy were my boss, I would have gone straight to every member of higher management with a well-written and documented list of complaints and gotten him fired. -1 for not having the balls to stand up for yourself.Bioclimatology
@muusbolla: Who told you we did not complain? It escalated until a delegation of two (including me) went straight to the CEO to explain the problem. But I'm sorry to have to tell you there is a difference between a idealistic world, where justice reigns, and the real world, where some bosses believe "the management is never wrong, even when it is", and will crush anyone that will dare to contradict that dogma. The only happy souvenir I have from that time is the day I resigned, almost three years ago, and I am a happier man since that day. Anyway, if true, your downmod reason is lame. Sorry.Perusse
You should check every error code. And flush out the resulting necessary error handling branch, as well.Baroness
T
131

Back in the 80's/90's, I worked for an aircraft simulator company that used FORTRAN. Our FORTRAN compiler had a limit of 8 characters for variable names. The company's coding standards reserved the first three of them for Hungarian-notation style info. So we had to try and create meaningful variable names with just 5 characters!

Tgroup answered 20/10, 2008 at 11:38 Comment(14)
Luxury: we had just 6 characters; the package had names starting with g; the internal functions all started gk; there were workstation drivers with codes such as 0p (so gk0p was the start), leaving us two characters for the rest of the Fortran name. gk0paa, gk0pab, ...Unwearied
Oh - fortunately we did have a get out; some of the code was written in C and that which did not have to be called from Fortran could use longer names (at least 8 characters -- I forget the exact number now).Unwearied
"When I was your age, we only had 2 characters! And it was case-insensitive!"Eugenle
We used to have to get up at 2 in the morning, 3 hours before going to bed, then write our own compilers and pay the company for the privilege of going to work. We were allowed just the letter A for our variable names. Then our boss would delete our code and dance on our listings singing hallelujah.Tgroup
Yeah, I know Monty Python too... The 'me too, only better/worse' story is, in fact, true. The package was for the GKS (Graphical Kernel System), hence the initial 'g'. It teaches a name-space discpline, though.Unwearied
"50 possible identifiers ought to be enough for anyone" :pRiebling
Pookleblinky--there really were systems with those rules. The second computer I ever worked with.Huttan
If you think that's hard, look at this: #218623Vaporimeter
That's not so bad! I used to code in RPG/400, where variables had only 6 positions, and the first 2 were reserved as a table prefix. So only 4 chars left for meaninful stuff ;-)Amalle
That sucks, but at least there was a reason for it.Preconcerted
not only that, we had to make it compatible to a wide range of compiers from the ancient FORTRAN-S to vsFort-77 (with 66 compatibility)Gamopetalous
Heck, the BASIC interpreters we worked with a long time ago had two-character variable names. Why complain about 5?Cotta
I did work with a BASIC variant that only allowed one character for variable names. Even to a real greenhorn (like I was then) it was obvious that that was a toy system and not something to take seriously.Inelegancy
@Donal, reminds me of 'programming' on my TI-83 calculator (in simplified Basic). I was 15, a complete noob, and even back then I kind of had this feeling there was something not entirely right with 1-char variables.Faucet
S
107

I worked at a place that had a merger between 2 companies. The 'dominant' one had a major server written in K&R C (i.e. pre-ANSI). They forced the Java teams (from both offices -- probably 20 devs total) to use this format, which gleefully ignored the 2 pillars of the "brace debate" and goes straight to crazy:

if ( x == y ) 
    {
    System.out.println("this is painful");
    x = 0;
    y++;
    }
Saturated answered 20/10, 2008 at 11:38 Comment(16)
ps. The silly 'reason' was so that it would be easier for people to transfer context from C to Java and vice-versa.Saturated
I would think that maintaining a greater visual distinction between C and Java would make the transitions easier. (+1 for "and goes straight to crazy.")Strawflower
Looks like Whitesmiths style which was used in the original 'Programming Windows' by Petzold - go figure! ;)Effendi
This seems to be the style favoured by brian d foy, who's a member of stackoverflow: search.cpan.org/src/BDFOY/Business-ISBN-2.03_01/lib/ISBN.pmSpouse
I remember seeing that when I was first starting in C. Always disturbed me a bit--I guess because the braces are part of the if statement, not the looping code,Weitman
its pretty much using python style - only python dumped the braces as they're redundant in this style.Siding
I always use the Perl style formatting, because it makes it easier to tell when you're just in a block for scoping reasons.Borrero
Good that they at least allowed declaring scope variables not only at the beginning of the block. ;)Nit
I've seen this style from people whose first programming language used 'begin' and 'end' keywords. I theorize that they are mentally translating "{" to "begin" and "}" to "end". I don't know; there may be other reasons, too.Maihem
I find this the most intelligent brace style. Unfortunately, most people don't use it. If braces have semantic meaning, they should be treated like it, not stuck at the end of a line and ignored.Agnesse
@Kyralessa. I disagree... I don't know if braces have semantic meaning but they can certainly affect pattern-matching and a sense of space. IMO, this version loses that completely. e.g. I want my bookmark to poke outside the book, not be flush with the pages.Saturated
I have seen this style before. The idea is that indentation shows nesting. Many people prefer this over having the { and } on the same level as the previous statement and just the sub statements indented. I prefer { on the line above and } on the same indentation as the statement causing the {}Auspicate
This is actually my preferred style, but everything in the world (Visual Studio especially) defaults to other modes, so I've given up. Why do I like it? The braces are "part of" the contained code -- they force it to "look like" a single statement to the if, which is what it expects.Steric
My workplace does this (and for Java). It made me twitch for a couple of weeks, but I got used to it pretty quickly and I like it now. It's better than "OTBS", at least (I was an ANSI/Allman guy before).Kilk
This was also my preferred style, but this whole comment thread is the best reason why I like Python now - no bickering over where the braces go!Jurassic
@Michael: Braces do have semantic meaning in C and many other languages derived from it (they denote the scope of variable contexts).Inelegancy
I
104

Forbidden:

while (true) {

Allowed:

for (;;) {
Ingemar answered 20/10, 2008 at 11:38 Comment(13)
I read somewhere that used to be that some compilers would generate a CMP and a JME (or equiv) instruction for the first example, and just an unconditional JMP for the second. I doubt that is still the case.Stillwell
Others have argued that for (;;) { is a C Idiom for the first.Illuminating
If I understand modern, new-fangled smileys correctly, this standard is making the poor, overworked for statement cry!Noblewoman
This is a de facto rule here. VC6 issues a compiler warning about while(true), but not about for(;;). Otherwise they're equivalent. So we pick the warning-free one.Tafia
Bjarne S. said in his book, "for (;;) should be read as forever". If it's good enough for the creator of C++, it should be good enough for you. :-)Pankhurst
Somewhat related questions (both mine): https://mcmap.net/q/18776/-infinite-loops-top-or-bottom-closed and #224921Baroja
In the very first C program I worked on, someone had added #define ever (;;) so you could say "for ever {...}"Easy
there is a reason for it: while (true) {...} generates a warning on some compilersKeitel
Most code written targets a particular compiler suite - have your makefile squash that warning, and then then they're equivalent.Groundsheet
Everyone knows for (;;) is much faster and less error-prone ;)Biagio
I... what? while(true) looks and flows nicer than for(;;).Seeseebeck
Forced on us: #define EVER (;;) ... for EVER { ...Flatboat
I recall an old version of a lint utility that I used back in the 80s, that gave a warning for the while and suggested changing it to the for.Entomology
M
101

a friend of mine - we'll call him CodeMonkey - got his first job out of college [many years ago] doing in-house development in COBOL. His first program was rejected as 'not complying with our standards' because it used... [shudder!] nested IF statements

the coding standards banned the use of nested IF statements

now, CodeMonkey was not shy and was certain of his abilities, so he persisted in asking everyone up the chain and down the aisle why this rule existed. Most claimed they did not know, some made up stuff about 'readability', and finally one person remembered the original reason: the first version of the COBOL compiler they used had a bug and didn't handle nested IF statements correctly.

This compiler bug, of course, had been fixed for at least a decade, but no one had challenged the standards. [baaa!]

CodeMonkey was successful in getting the standards changed - eventually!

Multiple answered 20/10, 2008 at 11:38 Comment(4)
Steven, this reminds me the monkey experiment story :o) freekvermeulen.blogspot.com/2008/08/…Goncourt
@[Nick D]: yes, me too - hence the code-name "CodeMonkey" ;-)Multiple
Or Grandma's Cooking Secret...Waldenburg
The reason might have been wrong, but it is still good to avoid nested ifs - c2.com/cgi/wiki?ArrowAntiPatternJaniculum
K
97

Once worked on a project where underscores were banned. And I mean totally banned. So in a c# winforms app, whenever we added a new event handler (e.g. for a button) we'd have to rename the default method name from buttonName_Click() to something else, just to satisfy the ego of the guy that wrote the coding standards. To this day I don't know what he had against the humble underscore

Kaylenekayley answered 20/10, 2008 at 11:38 Comment(12)
I'm wondering if you worked with me a couple years ago at a 9-month contract. We had the same BS. I understand following the framework guidelines (no underscores) in general, but since VS generates handlers with that syntax (whether via designer or +=) ... Well ...Subcritical
Ah, I took a quick gander at your profile and realized that you did not. Interesting that you dealt with an egotistical coding standard loony who had some of the same quirks as one I dealt with!Subcritical
Maybe _ was broken on his keyboard ;)Secluded
buttonNameUnderscoreClick()Selene
Well->maybe_he_was(tired_of, exceptionally_long_underscore_names, and_so_banned, them_from_use);Illuminating
Has the unfortunate side-effect of preventing the use of FILE and LINE for debugging. And #if __cplusplus extern "C" in header files. And the integral types in stdint.h. And size_t.Haemato
And pretty much all of the C++ standard library.Caseycash
Good thing this was C# thenTadeas
I seriously discourage underscores (although not in the OP case listed above. It's an extra two keystrokes (shift + _) that I prefer not to have put upon me when pascal or camel case will do just fine.Guillaume
underscores are seriously useful way of having a style in C that can be followed. When we have an existing C library file written with functions_like_this, I hate it when someone adds justOneFunctionLikeThis to the library_with_all_underscores. Some people. How about, try to fit in, more than to impose yourself on others?Smalley
There was an April Fools gag at a company I used to work it. Someone sent out a fake memo saying that the letter o was to be banned in C code (backed up by examples of bad keywords/functions that contained it such as goto, continue and longjmp.)Darra
People with carpel tunnel can have a hard time doing the pinky stretch to hit the underscore. Perhaps that is the origin of the standard?Alexei
C
92

Totally useless database naming conventions. Every table name has to start with a number. The numbers show which kind of data is in the table.

  • 0: data that is used everywhere
  • 1: data that is used by a certain module only
  • 2: lookup table
  • 3: calendar, chat and mail
  • 4: logging

This makes it hard to find a table if you only know the first letter of its name. Also - as this is a mssql database - we have to surround tablenames with square brackets everywhere.

-- doesn't work
select * from 0examples;

-- does work
select * from [0examples];
Copybook answered 20/10, 2008 at 11:38 Comment(2)
I am sorry, so terribly sorry...Commandment
Wow - good one. I guess using Letters was out of the question? Not that THAT is a good idea either but at least you don't have to quote all table names.Cravens
Y
90

We were doing a C++ project and the team lead was a Pascal guy.

So we had a coding standard include file to redefine all that pesky C and C++ syntax:

#define BEGIN {
#define END }

but wait there's more!

#define ENDIF }
#define CASE switch

etc. It's hard to remember after all this time.

This took what would have been perfectly readable C++ code and made it illegible to anyone except the team lead.

We also had to use reverse Hungarian notation, i.e.

MyClass *class_pt  // pt = pointer to type

UINT32 maxHops_u   // u = uint32

although oddly I grew to like this.

Yorkist answered 20/10, 2008 at 11:38 Comment(7)
Building unmaintainable code for the futureGenu
Hungarian notation done right is okay. Done wrong... ick. A proper type system beats both.Heartstrings
You know, I think I'm with you on that. The hungarian warts aren't nearly so objectionable when tacked onto the end like that.Flagitious
haha takes me back to the days when I switched from Pascal to C++ (about 16 years ago). Every time I saw a { I had to mentally tell myself "{ means BEGIN". At least for me it was just in my head.Riding
Wasn't there an old shell that was written entirely like this? Basically to the point where it didn't even resemble C.Mesh
I can understand the begin/end stuff--{} look too much like ()!Huttan
When I worked in MS VC++ support, we had several customers submit repro code written like this. It took a while for us to realize it was actually in C++ (they didn't include the #defines).Rhonarhonchus
D
88

At a former job:

  • "Normal" tables begin with T_
  • "System" tables (usually lookups) begin with TS_ (except when they don't because somebody didn't feel like it that day)
  • Cross-reference tables begin with TSX_
  • All field names begin with F_

Yes, that's right. All of the fields, in every single table. So that we can tell it's a field.

Dharana answered 20/10, 2008 at 11:38 Comment(7)
and you had no special prefix for primary key fields???Taxi
@Czimi: I forgot to mention that. Every table has a field called FI_ID used as the primary key.Dharana
Holy sh... The T_guy who invented this nightmare should be killed with a F_gun and sent to TSX_hell.Spheroidicity
We had tbl and fld for all fields and tables. Completely useless...Tadeas
If your database also has 'view's, at least you know if you are accessing a table or a viewWhitmore
@jab: Fine, but why wouldn't you just prefix the views then? Surely you have more tables than views.Fascist
@configurator: You had “tbl” for all fields and “fld” for all tables? :-)))Yost
M
84

A buddy of mine encountered this rule while working at a government job. The use of ++ (pre or post) was completely banned. The reason: Different compilers might interpret it differently.

Meshwork answered 20/10, 2008 at 11:38 Comment(10)
Well, at that point you might as well give up, right?Commandment
Some one got bitten by not understanding the difference between postfix and prefix, claimed compiler bug, then inflicted it on other people, me thinks.Stillwell
Oddly, in C/C++ that did hold true, an instructor gave us an example from back in the day. Although, not sure if it still applies.Clair
Actually, they were right, in some circumstances. Banning seems a bit over the top though. Take for example, the line : a[i] = i++; i may get incremented before it is used to index a, or after. The language does not define this.Flagitious
He's right--the order of operations is not guaranteed when you use the same variable elsewhere in the statement. Just ban potentially ambiguous code, not all uses of it, though!Huttan
@ted.dennison - Actually, the language specifically defines that line as illegal. (you may only use a variable once in a line, if you modify it)Easy
Why is this such a problem? You can still do i = i + 1 or i += 1?Trepang
@tuinstoel: Not in modern C++, you don't. You don't normally increment or decrement an iterator by adding or subtracting 1. @MagicKat: What probably happened was a line that modified a variable twice without an intervening sequence point, like i = i++;, which is undefined behavior. Banning undefined behavior is a good idea; banning all language constructs that can cause undefined behavior isn't.Cotta
At one time C was NOT standardized and this WAS a potential problem. Some AT&T docs mention it if I recall correctly. It was "clarified" fairly early on and the problem went away - for most people anyway.Coyote
Might as well ban = as it can be used to cause undefined behaviour.Tadeas
B
81

Half of the team favored four-space indentation; the other half favored two-space indentation.

As you can guess, the coding standard mandated three, so as to "offend all equally" (a direct quote).

Bemis answered 20/10, 2008 at 11:38 Comment(20)
see children, look what happens if you don't play nicely with others :-)Siding
Yes, the two spacers should have given in.Disinterested
Thats why tab identation is so great. Everyone can change the size in his editor ;)Appanage
Yeah, tab indentation is great... until you actually open someone else's file, and find things misaligned because spaces got mixed in where they shouldn't have, or didn't get mixed in where they should have. Then you auto-reformat, and version control diffs get ugly. Ugh.Maihem
I agree with Alan. mixing tabs and spaces makes for code that only looks right on one person's machine. Using three spaces (my preferred method) looks beautiful always. Although my code doesn't.Thickknee
that's why you're supposed to use only tabs to indent, and only spaces to align, and never the twain shall meet. and if you're going to make a change to the whitespace in a file, then that needs to be the only change you make for that particular check-in.Fuhrman
...and that never works. :PIlluminating
I recommend to people with indenting problems to statistically determine the original authors tab indention and replace it with tabs. Works surprisingly well.Neuromuscular
That's how I came to love AccuRev's option to "Ignore Whitespace" when diffing. Simply awesome.Malachite
I don't see the problem here. There needed to be a standard, and somebody had to mandate something. The phrasing was a little odd, I'll grant you, but the reasoning was OK.Cotta
3 seems like a fine decision to me but maybe I'm just one of those wimpy Europeans who likes compromises too much.Trepang
To "offend all equally"... I love it. I'm going to have to remember this the next time I'm somehow invloved in an indentation standardization war.Contrive
Strangely enough Visual Studio has spaces set as default. This has one advantage though: Since I always have visible white-space activated, I can detect changes in my own (tab formatted) code touched by other devs (defaulty space formatted) on first sight :)Bartizan
I use mixed-tab/space in the proper way, and never do the wrong thing, because my editor greenlines if I do (similar to incorrect grammar in Word).Length
Erm... use an decent text editor and change it there? Tabs can be rendered diffrently, and a nice Format tool goes long ways.Seeseebeck
For indentation, having a disagreeable coding standard is still better than having no standard at all. Developers will get used to whatever they're told to use.Distinctive
@Distinctive Agreed, but that's a false dichotomy. When half the team preferred A, and half preferred B, I would rather have had one or the other, even if it's not the one I preferred! If I want a blue car (but red would be acceptable) and my wife wants a red car (but blue would be acceptable), buying a purple car is not a good solution.Bemis
@joh6nn: The problem really comes when you've got trailing-line comments. There is just no way to make those align without standardizing tab widths between developers.Inelegancy
The best advice I've seen in this area is to separately standardize tab behavior and indentations, and to not conflate the two. (The Tcl coding spec says that tabs are 8 chars and indents are 4, and it says nothing about whether you indent with tabs.)Inelegancy
@Donal: There is just no way to make those align without standardizing tab widths between developers. - Yes there is. If you simply stick to the rule of using tabs for indentation and spaces for alignment (which is what @Fuhrman said).Lorie
O
74

Not being able to use Reflection as the manager claimed it involved too much 'magic'.

Ody answered 20/10, 2008 at 11:38 Comment(8)
Yeah, magic is hard to maintain, appearantly ;) LOL, though.Espalier
That's probably the right rule, for the wrong reasons :)Effendi
for 'magic' read performance killing unmaintainable obscure nightmare code. He's right.Siding
Reflection does tend to cause nightmare stack traces, which is my main objection. I'm not too bothered about the performance aspects because I can always refactor for speed later.Staffer
I avoid using reflection for major parts of design, but an outright ban is silly.Leathaleather
No, it was not allowed, as he didnt understand it. Every piece of code had to be written at his 'level'.Ody
I guess you weren't allowed to code in .Net at all then. After all, a lot of how the framework executes is through reflection.Potentate
I had a manager once who didn't believe in source code control. We were only allowed to use the VCS (Rational Rose, unfortunately) with checkin and checkout scripts to keep it at a distance, and he would put stuff directly into production without backups. I've seldom been as happy to leave a place.Cotta
K
71

The very strangest one I had, and one which took me quite some time to overthrow, was when the owner of our company demanded that our new product be IE only. If it could work on FireFox, that was OK, but it had to be IE only.

This might not sound too strange, except for one little flaw. All of the software was for a bespoke server software package, running on Linux, and all client boxes that our customer was buying were Linux. Short of trying to figure out how to get Wine (in those days, very unreliable) up and running on all of these boxes and seeing if we could get IE running and training their admins how to debug Wine problems, it simply wasn't possible to meet the owner's request. The problem was that he was doing the Web design and simply didn't know how to make Web sites compliant with FireFox.

It probably won't shock you to know that that our company went bankrupt.

Kansu answered 20/10, 2008 at 11:38 Comment(3)
Three cheers for capitalism!Belicia
Yay for survival of the fittest...this guy didn't deserve to be running his own software business.Cravens
The last sentence was great. How could someone be taken seriously when they make decisions like this?Mesh
V
54

Using generic numbered identifier names

At my current work we have two rules which are really mean:

Rule 1: Every time we create a new field in a database table we have to add additional reserve fields for future use. These reserve fields are numbered (because no one knows which data they will hold some day) The next time we need a new field we first look for an unused reserve field.

So we end up with with customer.reserve_field_14 containing the e-mail address of the customer.

At one day our boss thought about introducing reserve tables, but fortunatly we could convince him not to do it.

Rule 2: One of our products is written in VB6 and VB6 has a limit of the total count of different identifier names and since the code is very large, we constantly run into this limit. As a "solution" all local variable names are numbered:

  • Lvarlong1
  • Lvarlong2
  • Lvarstr1
  • ...

Although that effectively circumvents the identifier limit, these two rules combined lead to beautiful code like this:

...

If Lvarbool1 Then
  Lvarbool2 = True
End If

If Lvarbool2 Or Lvarstr1 <> Lvarstr5 Then
  db.Execute("DELETE FROM customer WHERE " _ 
      & "reserve_field_12 = '" & Lvarstr1 & "'")
End If

...

You can imagine how hard it is to fix old or someone else's code...

Latest update: Now we are also using "reserve procedures" for private members:

Private Sub LSub1(Lvarlong1 As Long, Lvarstr1 As String)
  If Lvarlong1 >= 0 Then 
    Lvarbool1 = LFunc1(Lvarstr1)
  Else
    Lvarbool1 = LFunc6()
  End If
  If Lvarbool1 Then
    LSub4 Lvarstr1
  End If
End Sub

EDIT: It seems that this code pattern is becoming more and more popular. See this The Daily WTF post to learn more: Astigmatism :)

Vaporimeter answered 20/10, 2008 at 11:38 Comment(14)
No kidding. I bet it took forever to go through and remove all those SQL injections. ;-)Commandment
That is pure evilness. I am sure your boss/TL is an overlord just waiting for his opportunity.Insectivorous
Actually he is pretty nice in person and a good business man, but one would never know from these coding rules... :)Vaporimeter
omg, who the hell would come up with rules like this??? most importantly: how the hell does your team manage to code??Dees
RE: Rule 1; Does that mean your DB queries are like "SELECT * FROM customer"? (Yes, I prescribe to the school of thought that keywords should be uppercase)Pivoting
I'm not sure I understand your question (I'm not a native speaker) My personal queries are like that, because I find it easier to read, but that's not a rule. Is something wrong about it?Vaporimeter
I think he meant that you would select all fields by default so you got all the 'reserve' fields as well, without needing to specify them all.Mesh
maibe you could use code preprosessing, where you would write your code using meaningfull variables names and then replace it with the "correct ones" before compiling somegtinh like '%s/email/reserve_field_12/g' ;)Bastardy
Can't fathom a possible reason for adding RESERVE fields until they are needed. (unless the table actually stored some type of application-configured data)Vermiculite
The problem is, that on every database 1-5% of the customers have problems (mostly corrupted databases, Did I mention we have to work with Access/Jet?) Also the "migration tool" is somewhat fragile, so that we are going to avoid database updates, unless they become absolutly necessary...Vaporimeter
I imagine your dev team must be masters of reverse engineeringChisholm
How do numbered local variable names solve the problem? You still have the same number of identifiers... only relabelled. I don't get it.Soutache
@trinithis: It's the number of unique identifiers which is limited.Vaporimeter
You are creating obfuscated code by hand!!!Interlaminate
U
53

Back in my C++ days we were not allowed to use ==,>=, <=,&&, etc. there were macros for this ...

if (bob EQ 7 AND alice LEQ 10)
{
   // blah
}

this was obviously to deal with the "old accidental assignment in conditional bug", however we also had the rule "put constants before variables", so

if (NULL EQ ptr); //ok
if (ptr EQ NULL); //not ok

Just remembered, the simplest coding standard I ever heard was "Write code as if the next maintainer is a vicious psychopath who knows where you live."

Unworldly answered 20/10, 2008 at 11:38 Comment(5)
rofl .. writing fortran in C.Pneumothorax
i still do null == variable in c#. i know i don't need to worry about it, but i can't help myself. if I see it the other way I feel nervous. old habits die hard.Ardithardme
The last one about the psychopath would get some people killed almost immediately.Mesh
+1 for the vicious psychopath.Graciagracie
When posting code on forums, I'll sometimes use things like LT and SHL, to avoid having the operators get munged as HTML.Dessau
S
44

Hungarian notation in general.

Stormystorting answered 20/10, 2008 at 11:38 Comment(7)
Well, I like H/N for control on a page. It's much easier to find all the textbox controls in an IntelliSense dropdown when all I have to look for is txtFooBar.Batsman
If you've got that many controls on a page that you have to find them by type, you've got bigger usability problems.Damicke
HUngarian notation is not evil, just need to be used properly joelonsoftware.com/articles/Wrong.htmlTaxi
I will concede with respect to controls. Then Hungarian notation can be helpful. In general though, I think Hungarian notation is obsolete, and generally misused. It has drifted from it's original intention.Stormystorting
Horribly misused, yes. Wrong, no.Huttan
A lot of people start an interface name with an I, IEnumerable, IList... In .Net framework al the interfaces start with an I.Trepang
First: it's notationHungarian, not Hungarian notation. Second: Joel's article is enough so I won't say more. Follow that link by @Taxi .Sophiasophie
F
43

I've had a lot of stupid rules, but not a lot that I considered downright strange.

The sillyiest was on a NASA job I worked back in the early 90's. This was a huge job, with well over 100 developers on it. The experienced developers who wrote the coding standards decided that every source file should begin with a four letter acronym, and the first letter had to stand for the group that was responsible for the file. This was probably a great idea for the old FORTRAN 77 projects they were used to.

However, this was an Ada project, with a nice hierarchal library structure, so it made no sense at all. Every directory was full of files starting with the same letter, followed by 3 more nonsense leters, an underscore, and then part of the file name that mattered. All the Ada packages had to start with this same five-character wart. Ada "use" clauses were not allowed either (arguably a good thing under normal circumstances), so that meant any reference to any identifier that wasn't local to that source file also had to include this useless wart. There probably should have been an insurrection over this, but the entire project was staffed by junior programmers and fresh from college new hires (myself being the latter).

A typical assignment statement (already verbose in Ada) would end up looking something like this:

NABC_The_Package_Name.X := NABC_The_Package_Name.X + 
  CXYZ_Some_Other_Package_Name.Delta_X;

Fortunately they were at least enlightened enough to allow us more than 80 columns! Still, the facility wart was hated enough that it became boilerplate code at the top of everyone's source files to use Ada "renames" to get rid of the wart. There'd be one rename for each imported ("withed") package. Like this:

package Package_Name renames NABC_Package_Name;
package Some_Other_Package_Name renames CXYZ_Some_Other_Package_Name;
--// Repeated in this vein for an average of 10 lines or so

What the more creative among us took to doing was trying to use the wart to make an acutally sensible (or silly) package name. (I know what you are thinking, but explitives were not allowed and shame on you! That's disgusting). For example, I was in the Common code group, and I needed to make a package to interface with the Workstation group. After a brainstorming session with the Workstation guy, we decided to name our packages so that someone needing both would have to write:

with CANT_Interface_Package;
with WONT_Interface_Package;
Flagitious answered 20/10, 2008 at 11:38 Comment(2)
With all that and NASA still couldn't figure out whether to calculate in kilometers or miles...Potentate
Damn, and I really thought you were going to go all out and use a CUN*_ and W*NK_ package naming convention. Sorry, I have slow-burning, explosive, textual tourettes. But yours were much, much, funnier!Strapped
S
41

When I started working at one place, and started entering my code into the source control, my boss suddenly came up to me, and asked me to stop committing so much. He told me it is discouraged to do more than 1 commit per-day for a developer because it litters the source control. I simply gaped at him...

Later I understood that the reason he even came up to me about it is because the SVN server would send him (and 10 more high executives) a mail for each commit someone makes. And by littering the source control I guessed he ment his mailbox.

Syringe answered 20/10, 2008 at 11:38 Comment(4)
Highlight email, click delete, doneSeeseebeck
I am definitely not a fan of so-called "chunky check-ins". Commit when your change is complete, simple as that. I also like to commit at the end of the work day as it enforces in my mind that my code should be compilable and be at least runnable with the rest of the project for other coders the next morning.Landgrabber
Get the best of both worlds - Commit to your local branch whenever you dont want to lose something. Rebase and squash those commits when you're ready to put them into master. (forgive the git terminology - I'm sure its possible in mercurial and a bunch of other systems too)Oviposit
I agree with all of the above. It's a rooted problem of approaching version control. It has no technological solution. I considered moving to git-svn, which would enable me to work with a local repository and then push things to the SVN repository, but that would have just sent the mails for all of my day's commits in one huge batch, and would have solved nothing for my bosses.Syringe
E
34

Doing all database queries via stored procedures in Sql Server 2000. From complex multi-table queries to simple ones like:

select id, name from people

The arguments in favor of procedures were:

  • Performance
  • Security
  • Maintainability

I know that the procedure topic is quite controversial, so feel free to score my answer negatively ;)

Ethnarch answered 20/10, 2008 at 11:38 Comment(16)
Performance is improved because SQL Server can more quickly identify the cached compiled form of the query. Security is improved because static compiled SQL stored procedures are not vulnerable to injection attacks. (continued)Strawflower
Maintainability could be improved if the table and column names are not unique, but the SP names are. This could make code references easier to find. If there are any other, better maintainability advantages, I am not aware of them. Security is the main reason to use SPs.Strawflower
I agree that for general purposes it's not 100% wtf, but see this link: codinghorror.com/blog/archives/000292.htmlEthnarch
In SQL2000, locking is an issue for some forms of DB architecture. It can kill performance totally. Putting your queries in SPs gets around that a lot as they're faster (and get less lock contention) and the DB can optimise some away, IIRC.Siding
It also provides very good abstraction from your database, this is a good thing, you should embrace it instead of trying to be a lazy programmer :-)Siding
This rule is probably a good idea if the database is maintained by an external team. If you are in control of the database, though, then it is a dumb idea.Financier
gbjbaanb, can you site your source? I'm interested in knowing more about this fact.Batsman
"Security is the main reason to use SPs" No. Nothing about SP's in SQL Server are more secure. They are only secure when called as a paremeterized queries, which can be done just as well with dynamic SQL.Oilskin
Performance: You should know that queries in SPs are not compiled, their execution plan is cached (this happens also in dynamic SQL). Maintainability: Database is for storing data. Keeping application behavior there doesn't sound "organized" to meEthnarch
stored procedures need to dieSoutine
Nah: sprocs are useful. While it can be a pain at times, you end up writing a better, more reusable database interface. Your dba's can also have an easier time analyzing performance problems and can update a production system without an app code change. I don't advocate biz logic in sprocs though.Pneumothorax
burying queries in compiled code is such a pain, I'm 100% behind 100% sprocs policy for the abstraction aloneAlcaraz
The big performance gain in sprocs comes when you have a variety of operations to perform to support a single business process. If you are going to perform 5-10 database operations within a transaction, all rooted in a few args, then a sproc saves the time needed to submit 5-10 calls.Cravens
You're right Mark, it's a good place to use them. With my post I meant that the real problem is when people abuses sprocs, using them for every database call.Ethnarch
Performance could be much worse as only single execution plan can be cached and that plan may be no good for for certain parameters passed to the procedure. SQL Server caches execution plans for adhoc queries anyway -- they don't even need to be prepared! Security is the same -- you must always escape any ad-hoc data sent to the server. Failure to do so will not prevent bad things from occuring. On maintainability they got you there :) I've lost track of the number of times I was able to "patch" a running system with no compiled code changes simply by updating procs.Basically
@Oilskin - this is incorrect. You're only thinking of injection attacks. Limiting access to only through SPs allows you to make all tables private, and the only access point through a limited set of procedures, each of which is explicitly permitted. The SPs can implement app-level security, and at the very least, prevent you from, e.g., INSERTing into system tables. These may not be the most important criteria for you, but they are real.Sheepshead
G
33

There must be 165 unit tests (not necessarily automated) per 1000 lines of code. That works out at one test for roughly every 8 lines.

Needless to say, some of the lines of code are quite long, and functions return this pointers to allow chaining.

Galvanize answered 20/10, 2008 at 11:38 Comment(8)
How is a unit test not automated.Belisle
How did they come up with the magic number 8?Function
I think that by "not automated" he means "not repeatable".Financier
One test per 8 lines is actually not very many at all... Do you mean you can have AT MOST 165 tests?Mcdaniel
What happens if you have 164? 166?Connote
More like 6 lines.Extensile
@Orion that depends heavily on the language.Early
It depends on how finely grained your tests are too I guess. I'd consider function(x).should == 2 to be a single test, whereas others would bundle 10 of those together and call it a single test.Mcdaniel
A
30

We had to sort all the functions in classes alphabetically, to make them "easier to find". Never mind the ide had a drop down. That was too many clicks.

(same tech lead wrote an app to remove all comments from our source code).

Assets answered 20/10, 2008 at 11:38 Comment(11)
Well sure, 'cause comments are just clutter, after all... and think how many cycles the pre-processor saves at compile time! (The app is even funnier than the rule. Good one.)Parodist
Of course! Developers are supposed to write code, not waste time writing comments :)Vaporimeter
Yeah! And comments make the build slower!Proliferate
Did that person actually use the IDE? I remember the ordering suggestion back in the days before IDEs....Have not heard much since.Helse
Yep, but that involved click instead of keyboard :)Assets
Nevertheless I think is a good rule to sort members by type (fields, properties, methods) and by nameArraignment
@Nat: Any rule without sense is evil without doubt! :)Arraignment
I sort methods, members, etc. alphabetically within their respective groups, in both header and source...but only because I'm obsessive.Keelia
This is not so silly if you use paper printouts for code reviewsDarra
Programming via 8-hole punched tape in the 1970's, we weren't allowed to include comments because they made it more likely that you'd get a parity error when reading the tape. We got line printer listings from the computer centre and we transcribed the comments (in pencil) from the previous listing.Butadiene
Man, sitting her running Visual Studio 2010 and just stringing together SharePoint framework calls, that situation is really hard to imagine...Assets
M
29

In 1987 or so, I took a job with a company that hired me because I was one of a small handful of people who knew how to use Revelation. Revelation, if you've never heard of it, was essentially a PC-based implementation of the Pick operating system - which, if you've never heard of it, got its name from its inventor, the fabulously-named Dick Pick. Much can be said about the Pick OS, most of it good. A number of supermini vendors (Prime and MIPS, at least) used Pick, or their own custom implementations of it.

This company was a Prime shop, and for their in-house systems they used Information. (No, that was really its name: it was Prime's implementation of Pick.) They had a contract with the state to build a PC-based system, and had put about a year into their Revelation project before the guy doing all the work, who was also their MIS director, decided he couldn't do both jobs anymore and hired me.

At any rate, he'd established a number of coding standards for their Prime-based software, many of which derived from two basic conditions: 1) the use of 80-column dumb terminals, and 2) the fact that since Prime didn't have a visual editor, he'd written his own. Because of the magic portability of Pick code, he'd brought his editor down into Revelation, and had built the entire project on the PC using it.

Revelation, of course, being PC-based, had a perfectly good full-screen editor, and didn't object when you went past column 80. However, for the first several months I was there, he insisted that I use his editor and his standards.

So, the first standard was that every line of code had to be commented. Every line. No exceptions. His rationale for that was that even if your comment said exactly what you had just written in the code, having to comment it meant you at least thought about the line twice. Also, as he cheerfully pointed out, he'd added a command to the editor that formatted each line of code so that you could put an end-of-line comment.

Oh, yes. When you commented every line of code, it was with end-of-line comments. In short, the first 64 characters of each line were for code, then there was a semicolon, and then you had 15 characters to describe what your 64 characters did. In short, we were using an assembly language convention to format our Pick/Basic code. This led to things that looked like this:

EVENT.LIST[DATE.INDEX][-1] = _         ;ADD THE MOST RECENT EVENT
   EVENTS[LEN(EVENTS)]                 ;TO THE END OF EVENT LIST

(Actually, after 20 years I have finally forgotten R/Basic's line-continuation syntax, so it may have looked different. But you get the idea.)

Additionally, whenever you had to insert multiline comments, the rule was that you use a flower box:

************************************************************************
**  IN CASE YOU NEVER HEARD OF ONE, OR COULDN'T GUESS FROM ITS NAME,  **
**  THIS IS A FLOWER BOX.                                             **
************************************************************************

Yes, those closing asterisks on each line were required. After all, if you used his editor, it was just a simple editor command to insert a flower box.

Getting him to relent and let me use Revelation's built-in editor was quite a battle. At first he was insistent, simply because those were the rules. When I objected that a) I already knew the Revelation editor b) it was substantially more functional than his editor, c) other Revelation developers would have the same perspective, he retorted that if I didn't train on his editor I wouldn't ever be able to work on the Prime codebase, which, as we both knew, was not going to happen as long as hell remained unfrozen over. Finally he gave in.

But the coding standards were the last to go. The flower-box comments in particular were a stupid waste of time, and he fought me tooth and nail on them, saying that if I'd just use the right editor maintaining them would be perfectly easy. (The whole thing got pretty passive-aggressive.) Finally I quietly gave in, and from then on all of the code I brought to code reviews had his precious flower-box comments.

One day, several months into the job, when I'd pretty much proven myself more than competent (especially in comparison with the remarkable parade of other coders that passed through that office while I worked there), he was looking over my shoulder as I worked, and he noticed I wasn't using flower-box comments. Oh, I said, I wrote a source-code formatter that converts my comments into your style when I print them out. It's easier than maintaining them in the editor. He opened his mouth, thought for a moment, closed it, went away, and we never talked about coding standards again. Both of our jobs got easier after that.

Marashio answered 20/10, 2008 at 11:38 Comment(2)
+1 for the comment formatter when printingVermiculite
The flower box should NEVER be overused. I hate it when I'm reading along code, okay nice comment, then see a flower box screaming "THIS DOES THIS AND THIS AND THIS"Seeseebeck
S
26

An externally-written C coding standard that had the rule 'don't rely on built in operator precedence, always use brackets'

Fair enough, the obvious intent was to ban:

a = 3 + 6 * 2;

in favour of:

a = 3 + (6 * 2);

Thing was, this was enforced by a tool that followed the C syntax rules that '=', '==', '.' and array access are operators. So code like:

a[i].x += b[i].y + d - 7;

had to be written as:

((a[i]).x) += (((b[i]).y + d) - 7);
Saguenay answered 20/10, 2008 at 11:38 Comment(1)
maybe (((a)[(i)]).x) += (((((b)[(i)]).y) + (d)) - (7)); ?Intoxicant
B
26

At my first job, all C programs, no matter how simple or complex, had only four functions. You had the main, which called the other three functions in turn. I can't remember their names, but they were something along the lines of begin(), middle(), and end(). begin() opened files and database connections, end() closed them, and middle() did everything else. Needless to say, middle() was a very long function.

And just to make things even better, all variables had to be global.

One of my proudest memories of that job is having been part of the general revolt that led to the destruction of those standards.

Berna answered 20/10, 2008 at 11:38 Comment(4)
I guess on paper in a meeting room it sounded good, but I pity the programmer who had to follow itSeeseebeck
Must've been designed by an English teacher.Angelynanger
Must have been designed by a COBOL programmer.Salena
Must have used a lot of goto's.Clannish
P
25

Prefix tables with dbo_

Yes, as in dbo.dbo_tablename.

Pampas answered 20/10, 2008 at 11:38 Comment(3)
LOL, I have a project right now that is sending to another company and that is the way they want the column names in the Excel files we are to send them. I knew that the names had to be the column names in their database (as they wouldn't let us replace them with names that actually made sense in context of the report.)Algesia
Because looking at dbo.tablename is such an eyesore...Seeseebeck
What happens to tables not in dbo? :)Straight
S
25

My weirdest one was at a contract a couple years ago. @ZombieSheep's weird one was part of it, but not the weirdest one in that company.

No, the weirdest one in that company was the database naming scheme. Every table was named in all caps, with underscores between the words. Every table had a prefix (generally 1 - 6 characters) which was usually an acronym or an abbreviation of the main table name. Every field of the table was prefixed with the same prefix as well. So, let's say you have a simple schema where people can own cats or dogs. It'd look like this:

PER_PERSON
    PER_ID
    PER_NameFirst
    PER_NameLast
    ...
CAT_CAT
    CAT_ID
    CAT_Name
    CAT_Breed
    ...
DOG_DOG
    DOG_ID
    DOG_Name
    DOG_Breed
    ...
PERCD_PERSON_CAT_DOG (for the join data)
    PERCD_ID
    PERCD_PER_ID
    PERCD_CAT_ID
    PERCD_DOG_ID

That said, as weird as this felt initially ... It grew on me. The reasons behind it made sense (after you wrapped your brain around it), as the prefixes were there to be reminders of "recommended" (and enforced!) table aliases when building joins. The prefixing made the majority of join queries easier to write, as it was very rare that you'd have to explicitly reference a table before the field.

Heck, after a while, all of us on the team (6 people on our project) were able to begin referring to tables in conversation by nothing more than the prefix. An acquired taste, to be sure ... But one that grew on me. So much so that I still use it, when I have that freedom.

Subcritical answered 20/10, 2008 at 11:38 Comment(2)
My experience is Oracle people like to do things like this.Hewett
That probably was the case -- it was a SQL Server environment, but I'm pretty sure most of the standard-setting DBAs had heavy Oracle backgrounds. In any event, we can now count another dyed-in-the-wool SQL Server guy as liking it ... Like I said, it grew on me. :)Subcritical
T
22

Several WTF's in one VB6 shop (I'm not proud, I was hungry and needed to eat) back in 2002 - 2004.

The most annoying IMHO, was setting all object references to nothing at the end of the sub/function. This was to "help" the compiler reference count. It didn't matter how many tests I performed for the TA to prove it wasn't necessary, Oh no, it still had to be done, even though he had absoutely no evidence to back him up what so ever. Eventually I gave up and about a year later found an article explaining why it was pants. I bring this to the TA thinking "Got the fecker!". He goes "Yeah, I've known about that for years, but if you start changing the standard the sheep " meaning other developers, the people he worked with everyday "will screw it up". Gob sh1te.

Others in the same shop.

  • Never delete code, always comment it out (even though we were using source control).
  • Prefixes on table names that were meaningless when I got there, but had to be enforced on new tables.
  • Prefixing all objects with o_ (lo_ for procedure level references, mo_ for module, go_ for global). Absoutely pointless in a project where every other variable was an object reference.

Mostly I was writing c++ there (only c++ developer, so made own standards, and enforced with rigor!) with occasional vb, otherwise I wouldn't have lasted.

Tintometer answered 20/10, 2008 at 11:38 Comment(3)
Sadly, at my last job we were working with Java, and haing OutOfMemory issues and seemed to have a memory leak. The consulting company we were working with actually proposed and implemented, setting every variablse back to null at the end of methods. Needless to say, the problems didn't go away :)Partheniaparthenocarpy
TA = Technical Architect, or Technical Guru, a role often appointed, rarely earned. The guy at my current job is EXCELLENT, he raises the bar for everyone.Tintometer
"Never delete code." I just imagine my starting days, when there was no syntax coloring by default. Then this would count as torture.Olivann
P
20

Every beginning and ending brace was required to have a comment:

public void HelloWorld(string name)
{

  if(name == "Joe")
  {
    Console.WriteLine("Hey, Joe!");
  } //if(name == "Joe")
  else
  {
    Console.WriteLine("Hello, " + name);
  } //if(name == "Joe")
} //public void HelloWorld(string name)

That's what led me to write my first Visual Studio plugin to automate that.

Postobit answered 20/10, 2008 at 11:38 Comment(8)
God I hate those types of comments - all they do is add visual litter to the screenFoam
Generally I agree, @matt ... But when you're handed a 444-line VBScript classic ASP page littered with very long (90+ LOC) nested ifs, it can be tremendously helpful. Assuming, of course, that the original developer matched them correctly. Which, in code like that, may not be a safe assumption!Subcritical
if you have very long nested if's, then this kind of comments is just a little duct tape instead of a real fix (that is, extracting methods and such)Fourfold
the rule you need in that case should be "no crazy nested ifs"Dees
OMG! Don't most IDE text editors do curly-brace highlighting/matching now?Rhonarhonchus
*clicks minimize button in IDE. Oh, thats what it doesSeeseebeck
So why do none of the beginning braces in your example have comments?Landgrabber
These are actually very common in C headers(#ifndef __HEADER_H__ #define __HEADER_H__ #endif /* __HEADER_H__ */)Tholos
H
14

Wow -- this brings back so many memories of one particular place that I worked: Arizona Department of Transportation.

There was a project manager there that didn't understand object-based programming (and didn't want to understand it). She was convinced that object-based programming was a fad, and refused to let anybody check-in code that used any kind of object based programming.

(Seriously -- she actually spent a lot of her day reviewing code that we had checked-in to Visual SourceSafe just to make sure we weren't breaking the rules).

Considering Visual Basic 4 had just released (this was about 12 years ago), and considering that the Windows forms application we were building in VB4 used objects to describe the forms, this made development ... complicated.

A buddy of mine actually tried to get around this problem by encapsulating his 'object code' inside dummy 'forms' and she eventually caught on that he was just (* gasp *) hiding his objects!

Needless to say, I only lasted about 3 months there.

Gosh, I disliked that woman's thinking.

Harman answered 20/10, 2008 at 11:38 Comment(8)
It baffles me how such people even get hired????Waylonwayman
Hiring decisions are often made by people with no technical skills, and certain sorts of horribly incompetent people are great at bluffing these interviews with lots of snazzy buzzwords.Onomatopoeia
@Roberto: Almost certainly seniority. She had presumably started with the state a long time ago, and had been promoted through seniority. This guarantees that the management does have a lot of experience, but not that it's anywhere near the right kind of experience.Cotta
Actually -- she was a contractor. Didn't have much senority in terms of years.Harman
OOP is a fad. Hmm. en.wikipedia.org/wiki/Object-oriented_programming#OOP_languagesSeeseebeck
I'm sure she probably thinks Wikipedia is either inaccurate or a fad, too. ;-)Harman
I'm amazed. I bet she ended up with a pretty good grasp of OOP anyway in order to detect all the obfuscations used to get round her.Straight
LOL. I'd like to think so ... but she sure didn't let on.Harman
H
13

What drives me nuts is people suffixing the ID field of a table with the name of the table. What the hell is wrong with just ID? You're going to have to alias it anyway... for the love of all that is sacred!

Imagine what your SQL statements look like when you've got id fields called IDSEWEBLASTCUSTOMERACTION and IDSEEVENTLOGGER.

Honorarium answered 20/10, 2008 at 11:38 Comment(5)
Actually I think it makes queries easier to write and read. I do this. SELECT * FROM Person P LEFT JOIN PhoneNumber PN ON P.PersonID = PN.PersonIDHewett
my preference: ... from customer left join address on (address.id = customer.address_id)Riebling
Why do you have alias it anyway? Don't understand.Trepang
The OP is talking about putting the table name after 'ID', which is just weird.Rhonarhonchus
Putting it before is debatable, in certain situations it makes stuff cleaner. However, putting after is just dumbSeeseebeck
E
12

You must use only five letter table names and the last two character is reserved for IO.

Enamel answered 20/10, 2008 at 11:38 Comment(0)
T
11

(Probably only funny in the uk)

An insurer I worked at wanted a combination "P" or "L" to denote the scope, concatenated with hungarian for the type, on all properties.

The plus point was we had a property called pintMaster! Made us all fancy a drink.

Topi answered 20/10, 2008 at 11:38 Comment(1)
+1 ...and to people who enjoy UK shows :)Introductory
C
11

The team size was about a dozen. For C# methods we had to put a huge XML formatted function before every function. I don't remember the format exactly but it involved XML tags nested about three to five levels deep. Here's a sketch from memory of the comment.

/// <comment>
/// </comment>
/// <table>
///    <thead>
///       <tcolumns>
///          <column>Date</column>
///          <column>Modified By</column>
///          <column>Comment</column>
///       </tcolumns>
///    </thead>
///    <rows>
///       <row>
///          <column>10/10/2006</column>
///          <column>Fred</column>
///          <column>Created function</column>
///       </row>
///    </rows>
/// <parameters>

I've got to stop there....

The downsides were many.

  • Files were made up mostly of comments.
  • We were not using our version control system for tracking changes to files.
  • Writing many small functions hurt readability.
  • Lots of scrolling.
  • Some people did not update the comments.

I used a code snippet (Emacs YAS) to add this code to my methods.

Cerulean answered 20/10, 2008 at 11:38 Comment(1)
XML formatted anything in code hurts readability. To be used at the head of every single function, thats just horribleSeeseebeck
D
11

Applying s_ to variables and methods which were deemed "safety critical" for software that was part of a control system. Couple this with the other rule about putting m_ on the front of member variables and you'd get something ridiculous like "s_m_blah()", which is darn annoying to write and not very readable in my opinion. In the end some 'safety expert' was supposed to gain insight by looking at the code and determining something from it by using those "s_" - in practice, they didn't know c++ too well so they couldn't do much other than make reports on the number of identifiers that we'd marked as 'safety critical'. Utter nonsense...

Dominik answered 20/10, 2008 at 11:38 Comment(5)
MS does this in vc++ with a suffix _s.Carnify
I've just spent the last five minutes trying to think of a joke about S & M. I'm sure there must be one. Probably not suitable to post here though.Costrel
Does the s_ always come before the m_?Borrero
Was the objective to write perverted code? <G>Huttan
@Brian: I thought that was because they added those _s functions later... had the functions been safe in the first place, they wouldn't have needed a variant.Tinsmith
A
11

The strangest one i saw was database table naming where the tables were prefaced with a TLA for functional area, eg accounting ACC then a 3 digit number to (overide the default sort) and then the table name.

Plus this was extended into the column names as well.

ACC100_AccountCode

it was a nightmare to read a query, they were so unreadable.

Asseveration answered 20/10, 2008 at 11:38 Comment(1)
I've seen this too. To make it worse, people started to refer to the tables with the shorthand of their number.. "that's in 452"Sultana
L
10

Not quite a coding standard, but in 1998 I worked for a company where C++ was banned, in favour of C. This was because OO was considered too complex for the software engineers to grasp.

In our C code we were required to prefix all semi-colons with a space

int someInt = 5 ;

I could never find out a reason for this, but after a while it did grow on me.

Languishment answered 20/10, 2008 at 11:38 Comment(4)
Well, Linus has stated that C++ is a horrible language: thread.gmane.org/gmane.comp.version-control.git/57643/…Trepang
I'm not impressed with Linus's ranting. He sounds very idealogical and biased. I'll stick with the STL - it's never broken for me.Agnes
I worked for a company in 2005 where C++ was eschewed in favor of C. (Because the default distro had a broken version of GCC, and clearly it was better to spend the extra man years to use C than it would have been to upgrade the compiler.)Mezereon
@Paul Nathan: Linus did a great thing bringing us a GPLed Unix, but I think he's done some things under his benevolent dictatorship that have hamstrung the whole process. The completely unstable driver APIs, for one. You get one version of the API that's open sourced, and then it stops working (vmware, promise, adaptec) with a kernel update. It's annoying and counterproductive. I've been using C++ since 1993 - aside from some rough spots when the STL first came out, it's been rock solid.Cribwork
A
10

If I remember correctly the delphi IDE did a default indent of two spaces. Most of the legacy code for the company had three spaces and was written by the VP IT and the CEO. One day, all the programmers were talking about what we should do to make our lives easier and a contractor who knew Delphi pretty well said, "Hey the ide defaults to two spaces does anyone have a problem with us doing this going forward for new code?" All of us looked at each other, and pretty much thought it was a no brainer and said that we agreed.

Two days later the VP and CEO found out we were going to make such a dangerous change that could "cause problems" and instructed us that we would be using three indents for everything until the two of them could accurately evaluate the impact of such a change. Now I am all for following standards, but these are the same people who thought oo programming was creating an object with one function that had all of the logic necessary to perform an action, and that source control was moving the code files to a different directory.

Assumpsit answered 20/10, 2008 at 11:38 Comment(4)
You can set the indent in the environment options!Huttan
Ah HA!! So THATs where three spaces comes from!Illuminating
I will never understand why people hate with a passion a simple space or tab.Seeseebeck
+1 because I just left a job where I started under one of these programmers, management couldn't understand why working with legacy code was so time consuming: "people who thought oo programming was creating an object with one function that had all of the logic necessary to perform an action, and that source control was moving the code files to a different directory"Coppage
P
10

It was a coding standard I did not follow myself ( got in trouble for other things, but never that ). We had three 19" monitors, so we could have two editors open to full screen and still have access to the desktop. Everyone else did not use comments, but used meaningful names. Extremely long meaningful names. The longest I remember was in the 80 character range. The average was around 40~50.

Guess what, they didn't accurately describe the whole thing.

Philippine answered 20/10, 2008 at 11:38 Comment(2)
for(int ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime = 0; ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime < 10; ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime++) ;Carnify
ITYM: for(int ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime = 0; ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime < 10; ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime+=2);Saguenay
G
9

In Java, when contracting somewhere that shall remain nameless, Interfaces were banned. The logic? The guy in charge couldn't find implementing classes with Eclipse...

Also banned - anonymous inner classes, on the grounds that the guy in charge didn't know what they were. Which made implementing a Swing GUI all kinds of fun.

Gamopetalous answered 20/10, 2008 at 11:38 Comment(1)
Perhaps eclipse.org/documentation ?Seeseebeck
L
9

One that no one has mentioned is being forced to write unit tests for classes that are brainless getters and setters.

Leathaleather answered 20/10, 2008 at 11:38 Comment(7)
I don't see this as a problem. It's a lot nicer to have this type of test and find that you made a simple mistake instead of having to spend significant time debugging a larger unit/integration test to find it. Besides, you can probably automate/template these tests if they're that bad.Foam
I failed to mention that our IDE has a menu item titled "Generate Getters and Setters..."Leathaleather
in that case, write yourself a script "Generate Getter- and SetterTests".Fourfold
They need to be tested. I was driven absolutely nuts by a bug eons ago--the answer turned out to be in the runtime library, a piece of code that amounted to a setter. To compound it, there was a bug in the debugger (continued)Huttan
Step through the code and it would work correctly. Execute it and you almost certainly got a protection violation. (The debugger swallowed the error and somehow produced a working result. This was possible as the data was correct, just not valid in a segment register.)Huttan
Shouldn't the setters and constructors be checking to make sure their inputs are legal and it leaves the object in a valid state?Subordinate
Of course not! "The database does that." (actual quote from co-worker)Leathaleather
G
8

In Java, I am currently discouraged to use boolean functions as a predicate in a test:

    if( list.isEmpty() )...

must be rewritten

    if( list.isEmpty() == true )...

and

    if( !list.isEmpty() )...

must be rewritten

    if( list.isEmpty() == false )...

because "it is clearer like that".

To me, "list.isEmpty() == true" has 2 verbs, "is" and "equals", in one phrase without a connective. I can't make it feel right.

Goneness answered 20/10, 2008 at 11:38 Comment(2)
Hmm, right "clearer". +one if list is empty is clearer than if "list is empty" is true.Tasimeter
Even "clearer" would be if( (list.isEmpty() == false) == true )...Thunderhead
V
8

Once I had to do a little DLL out of my team and when it was done I had to redo the job because I shouldn't have had used "else" in the code. When I asked why I was instructed not to ask why, but the leader of the other team just "didn't get the else stuff".

Ventre answered 20/10, 2008 at 11:38 Comment(3)
Didn't get the else stuff...? And this guy got hired how?Seeseebeck
I can say he came from the Cobol age and fell down in a OO project. I guess he came thru a portal directly from the 70's... ;) I remember that I put a huge comment explaining why I did that without "else", I didn't want to be blamed for that hidious code.Ventre
should have just done "else if True". Same function as else, and maybe the idiot can grasp that.Zins
M
8

I once worked on a VB.NET project where every method body was wrapped in the following Try...Catch block:

Public Sub MyMethod()
    Try
        ' Whatever
    Catch Ex As Exception
        Throw New Exception("MyClass::MyMethod::" + Ex.ToString())
    End Try
End Sub

Those who do not understand Exception.StackTrace are doomed to reinvent it, badly.

Maladminister answered 20/10, 2008 at 11:38 Comment(1)
That will be a "guru" who knows about all this new-fangled exception handling but still thinks in On Error GoTo. :-(Straight
H
8

I once had to spell out all acronyms, even industry standard ones such as OpenGL. Variable names such as glu were not good, but we had to use graphicsLibraryUtility.

Hypotension answered 20/10, 2008 at 11:38 Comment(1)
I hope you didn't use any software from GNU = "GNU is Not Unix".Kean
D
8

I was told that old code should be commented out rather than being removed; in case we needed to refer to the old code (yes, the code was in source control...). This doesn't seem that bad, until major changes are made. Then it becomes a nightmare, with entire sections deleted all over the code.

Dessert answered 20/10, 2008 at 11:38 Comment(2)
i often do that so that no one trys to fix my fix. I have had to leave comments like "please do not change this line, this is really the correct way to do this" when working on a "team" of programmers who would consistently re-introduce bugs that I fixed, because they were sure my fixes were wrong.Ardithardme
I sometimes to that actually, but I move them to the bottom. Its helpful in between commits.Seeseebeck
M
8

The one that got me was similar to the other poster's "tbl" prefix for SQL table names.

In this case, the prefix for all stored procedures was to be "sp_" despite the fact that "sp_" is a prefix used by Microsoft for system-level stored procedures in SQL Server. Well, they had their standards from an old, non-MS database and weren't about to change just because their standard might cause a stored procedure to collide with a system stored procedure and produce unpredictable results. No, that just wouldn't be proper.

Myranda answered 20/10, 2008 at 11:38 Comment(6)
Naming stored procedures with sp_ is also a performance hit -- MS SQL assumes that they're in the master DB, and when it can't find them, it regenerates the execution plan...Damicke
@Roger -- thanks for the info. I've inherited my fair share of these (my own standard usp_) from other developers; good to know about the performance hit.Subcritical
It is very common in my experience to prefix stored procs with sp_ in SQL Server. I have seen it in many places. I prefix procs with proc_ and functions with fn_.Hewett
sp was the prefix used by Sybase - long before MS SQL Server came into being (by adapting Sybase).Unwearied
doesn't it help when you see something like "SELECT * FROM vwPatients" to know you are referencing a view insteal of a table...that would be "SELECT * FROM tblPatients"Ditzel
@MBoy: Now when you don't have views...Tadeas
P
7

When using SQL Server, which has such big limits on table name length that I've never personally bumped into them, we were forced to use the naming convention from the older mainframe system, even though the new system never interacted with the mainframe database.

Because of the tiny limit on the table names, the convention was to give all the tables codenames, rather than meaningful descriptions.

So, on a system that could quite happily have had the "customer" table called "ThisIsTheCustomerTable", instead it was called "TBRC03AA". And the next table was called "TBRC03AB", and the next one called "TBRC03AC", and so on.

That made the SQL really easy to understand, especially a month after you'd written it.

Prudhoe answered 20/10, 2008 at 11:38 Comment(0)
I
7

Adding an 80 character comment at the end of each method so it is easy to find the end of the method. Like this:

void doSomething()
{
}
//----------------------------------------------------------------------------

The rationale being that:

  • some users don't use IDE's that have code folding (Ok I will give them that).
  • a space between methods is not clear since people may not follow the other coding standards about indenting and brace placement, hence it would be hard to find the end of a function. (Not releavent; if you need to add this because people don't follow your coding standard then why should they follow this one?)
Incorporeity answered 20/10, 2008 at 11:38 Comment(2)
The brace belongs at the beginning of the next available line. If people don't follow that, then they are probably going to be starving for workSeeseebeck
Yeah, the second reason really does not make sense.Importation
O
7

Being forced to have only 1 return statement at the end of a method and making the code fall down to that.

Also not being able to re-use case statements in a switch and let it drop through; I had to write a convoluted script that did a sort of loop of the switch to handle both cases in the right order.

Lastly, when I started using C, I found it very odd to declare my variables at the top of a method and absolutely hated it. I'd spent a good couple of years in C++ and just declared them wherever I wanted; Unless for optimisation reasons I now declare all method variables at the top of a method with details of what they all do - makes maintenance A LOT easier.

Olenta answered 20/10, 2008 at 11:38 Comment(0)
F
7

inserting line breaks
(//--------------------------------------------------------------------------------)
between methods in a c# project.

Frier answered 20/10, 2008 at 11:38 Comment(3)
ha, I had to do that in college. Good timesFinegrain
He he. Now, some IDE (like IntelliJ) can display such a line breaks, without modifying the source code itself...Enwomb
And this improves readability how?Seeseebeck
O
7

no single character variable names - even for a simple iterator like i. Had to use ii or something. I thought this was stupid.

Another one - perhaps the craziest of all, but maybe not a coding standard...

no STL allowed. and this was in 2007/2008. I left there soon after I found out about that nonsense. Apparently some idiots thought that there was no "standard" (As in 15 years ago...) I guess they missed the memo about stl being in the C++ standard...

Use of the stupid COM HRESULTs as return types for just about ALL methods - even if they are not COM. It was ludicrous. So now instead of returning some enumerated type or a useful value that indicates a result, etc, we had to look up what S_OK or E_FAIL or whatever meant in the context of each of the methods. Again, I left there shortly after that.

Owenowena answered 20/10, 2008 at 11:38 Comment(10)
sounds like someone was missing an algebraic Maybe type.Riebling
This HRESULT thing can be sort of OK. If you don't want to use exceptions, you should return a condition, and test it. An HRESULT is as good as any. Using it as the return value allows you to do this: HRESULT res; if ( FAILED(res= dothis(...)) || FAILED(res= dothat(...)) ) HandleError(res);Wilburwilburn
The purpose of ii instead of i is that it's easier to search for. But if you have an IDE that can do "Find Whole Word", it's not really a big deal.Agnesse
if the scope of an iterator variable is that long/large then there is something wrong with the coding. Arbitrary rules to try to make searching for variable names easier is a bad idea. Additionally, with the IDEs these days, who needs to do a search?Owenowena
HRESULTS are useless unless you are using COM. It is not a good idea to force that paradigm on better practices. UGH!Owenowena
I'm not too happy with i and never use it. Sometimes x, y and perhaps even z make excellent sense, though.Huttan
Using repeated characters for small variables (ii for example) does make them easier to search for. Searching for references to i will get anything that has i in it whereas searching for ii will get much fewer false positives. It's actually quite a good practice.Pauli
@Pauli Why in the world would you EVER need to search the code for an iterator variable? Good practice? Not likely.Owenowena
"No STL allowed" is all about context - if you want to expose a cross-platform interface which exposes containers, you MUST NOT use STL. Even different versions of MSVC might cause crashes. Consider an API returning an std::vector, where the client uses another MSVC version. And what about preventing memory fragmentation? If you're writing a serious game engine, don't use STL. And there are many more examples.Ojibwa
@asaf - this was all a single platform. It was about people at the top not being comfortable with templates of C++ - certainly not about any deep understanding about the technology or valid concerns.Owenowena
E
7

I worked in a place where the coding standard was one giant WTF: strange Hungarian notation, prefixing globals with 'g' and members with 'm' (so there were gems like gsSomeVariable), adding 'ref string sError' to every single function, instead of throwing exceptions (which was a BIG nono!).

The killer, though, was prefixing the function parameters with I_ for input parameters, and O_ for output parameters.

I work now in a much better place :)

Environ answered 20/10, 2008 at 11:38 Comment(11)
adding 'ref string sError' to every single function, that best practice they show in computer science 101 at my university!Kassi
Prefixing globals with 'g' is simpler than putting a "here be dragons" comment on every fucntion.Mata
don't know your platform, but this kind of stuff is typical VB6. Probably, if you're not in VB6, the person who made the rules comes from that background and wanted it to conform to what he's used to. It was wrong in vb6 too, but you know...Ardithardme
I really like the g, and m prefixes... I and O seem a bit weird...Carbonation
g_ for globals, p_ for parameters, l_ for local variables, cp_ for cursor paramaters ... I used that in PL/SQL programming. I don't think that's bad.Trepang
Porcupine Tree are awesome! :)Environ
Who me? I can tolerate the porcupine trees but to say that I like them... no, not really. Or do you mean someone else?Trepang
I think he meant me, since I have an icon of their album In Absentia, which is in my mind nothing short of a masterpiece.Environ
What's with the phrase 'here be dragons'? I've seen that at multiple companies - where is it from?Rhonarhonchus
@Rhonarhonchus en.wikipedia.org/wiki/Here_be_dragonsEnviron
I argue that g and m are good prefix because: Globals::variableName is annoying to type (and NEVER EVER use the C++ global scope) and this->variableName is also worse to type (compare this->okButton with mOkButton in a member function. Which is easier to type?)Calton
S
6

The last place I worked was primarily a C++ shop, and before I was hired my boss (who was the director of research and development) had issued a decree that "dynamic memory allocation is not allowed". No "new", not even a "malloc" -- because "those can lead to memory leaks if a developer forgets the corresponding delete/free operation". As a corollary to this particular rule, "pointers are also not allowed" (although references were totally acceptable, being both awesome and safe).

I repealed those rules (as opposed to, say, rewriting all our software in other languages) but I did have to add a few awesome rules of my own, like "you may not launch a new thread without written approval from someone qualified to do that sort of thing" based on an unfortunate series of code reviews (sigh).

Sudra answered 20/10, 2008 at 11:38 Comment(2)
So... should programming not be allowed because it can lead to segfaults?Zins
So you shoved Boehm GC in there and everyone lived happily ever after? And threads are for people who don't understand state machines. :-)Quintic
C
6

My coding standards gripes are pretty tame compared to some of the heinous stuff I've seen here, but here goes:

I was on a project where some of the developers insisted on the most peculiar form of indenting I've ever seen:

if (condition)
   {
      x++;
      printf("Hello condition!\n");
   }
else
   {
      y++;
   }

We were developing for an embedded environment with a really rotten debugger. In fact, printf(), hexdump() and the mapfile were the preferred method of debugging. This of course meant using static was forbidden and all global variables and functions had to be of the form modulename_variablename.

Checking in code with warnings was forbidden (not such a bad thing), but the compiler would warn about any conditional that was constant. Therefore, the old macro/statement trick of do { something(); } while(0) was forbidden.

Lastly, leaving a trailing comma on a enumerator list or initializer was considered lazy, and thus forbidden:

enum debuglevel
   {
      NONE,
      FATAL,
      WARNING,
      VERBOSE,   // Naughty, naughty!
   };

As I've said, rather tame. But as a follower of "The Ten Commandments for C Programmers", I found the unconventional bracing style absolutely maddening.

Circumstance answered 20/10, 2008 at 11:38 Comment(3)
That brace style is insane. I don't care if you're in the {\n camp (me) or the \n{ camp, that's a great compromise that everyone is sure to hate.Zins
Looks like the GNU standard. If you didn't tell EMACS any better, and asked it to format your C code, that's roughly how it would end up. In addition, I'm guessing your embedded platform was Symbian because they prescribe that brace/indent style.Quintic
This actually makes sense if you think about it. I would use this if it didn't look ugly.Heretical
B
6

The worst I've experienced was to do with code inspections. For some reason even though we had and used the diff tool of our vcs to see what had changed, when you wanted your code inspected you had to surround your changes in a file/function with some comment blocks like so:

/*********...80charswide...***
 * START INSPECT
 */

 some changed code...

 /*
  * END INSPECT
  *********...80charswide...****/

After the inspection you'd have to go back and remove all those comment blocks before committing. ugh.

Berkowitz answered 20/10, 2008 at 11:38 Comment(1)
Maybe the person/group doing the inspections hated SVN?Seeseebeck
M
6

We have to put a comment above every sql statement. So, you may have an sql statement as such

Select USER_ID FROM USERS WHERE NAME = :NAME;

And you still have to have a comment above it that would say:

Select USER_ID from the USERS table, where name equals the name entered.

Now, when the actual comment is longer than the code, and the code is simple enough for a second grader to read, i really don't see the point of commenting... But, alas, I have had to go back and add comments to statements just like this.

This has been on a mainframe, coding in cobol. Team size is usually about 4 or 5, but this rule has bitten everyone here from time to time.

Marquittamarr answered 20/10, 2008 at 11:38 Comment(2)
Well... It's the COBOL that's your problem! The designers of COBOL had a mindset that EVERYTHING had to be spelled out in what one may call "longest notation possible." ...I LITERALLY "threw the book away" when I read that to express subtraction I had to type the word SUBTRACT, and couldn't use -.Stocking
C'mon. You can use -. You have to do it in a COMPUTE statement, something like COMPUTE NET_PAY = HOURS_WORKED * RATE. Hey, what can you expect from a language where ZERO, ZEROS, and ZEROES are all reserved words, and mean exactly the same thing?Cotta
T
6

In Delphi we had to change from

if something then
begin
  ...
end
else
begin
 ...
end;

to

if something then begin
  ...
end else begin
 ...
end;

in a project with 1.5 million lines of code. Imagine how easy this was on source control, diff, and merge! It also led to forgetting begin and not noticing it right away when the compiler announced a superflous end.

Timothee answered 20/10, 2008 at 11:38 Comment(2)
Fortunately there are great code formatters for Delphi.Weiland
Well, we were using one at the time, but the rules were changed in maintenance phase...Timothee
M
5

The first programming job I had was with a Microsoft QuickBASIC 4.5 shop. The lead developer had been working in BASIC just about forever, so most of the advanced (!) features of QuickBASIC were off-limits because they were new and he didn't understand them. So:

  • No Sub/End Sub procedures. Everything was done with GOSUB
  • We were allowed to not number lines that weren't the target of GOTO or GOSUB. But GOTO targets has to be a numeric label, not a name.
  • Targets of GOSUB were allowed to be named, but the name had to prefixed by 'S' and a four digit number. All subroutines had to have the four digit number sorted in order in the source file. So a typical routine might be S1135InitializePrinter. You'd have to go and find the right routine to get the number, there were enough that you couldn't hope to remember them all.
  • No block IF/END IF. All IFs had to have either a single GOTO or GOSUB as the conditional statement.

That was a really fun job. No, seriously.

Mairamaire answered 20/10, 2008 at 11:38 Comment(1)
In an ideal world they should probably not let people who have extreme fear of change into the software field, I mean for their own sanity.Maugham
E
5

Our Oracle DBA's are insisting that we prepend the schema name onto table names, ie if your schema is hr_admin, your staff table would be hr_admin_staff, meaning the full name of the table in a cross schema query would be hr_admin.hr_admin_staff.

Elizabetelizabeth answered 20/10, 2008 at 11:38 Comment(2)
This is a horrible convention considering the maximum length of table name in Oracle is only 32 chars.Gregson
@Esko: I thought it was even worse than that - isn't the maximum length only 30 characters?Geraint
W
5

Marking private variables with an _ just to make sure that we know we are dealing with private variables within the class. Then using php's magic methods __get and __set to provide access to each of the variables as if they were public anyway...

Wrath answered 20/10, 2008 at 11:38 Comment(2)
I've seen that in a few libraries. Kinda strange, but isn't all that badSeeseebeck
I 100% prefer python's self. requirement to typing a single _. There's something much less graceful about _ (plus the fact that it can mean different things to different languages. self is pretty obvious to any English-speaker.)Zins
F
5

This isn't a coding standard issue, but is surely a tale of restrictive thinking. We had completed a short 4 week project in no less than 7 weeks. The schedule was loosely based on guestimating a feature list. The development process consisted of coding furiously. During the postmortem I suggested using milestones and breaking feature requests into tasks. Incredibly, my director dismissed my ideas, saying that because it was such a short project, we didn't need to use milestones or tasks, and asked for other suggestions. The room fell silent.

Language: Java, C++, HTML Team size: Two teams, totaling 10 engineers Which ill effects it caused you and your team: I felt like I was caught in a Dilbert cartoon.

Forelock answered 20/10, 2008 at 11:38 Comment(1)
For very small projects, it might be a bit of overkill. But for any developer team, set tasks and milestones make life EASIER!Seeseebeck
P
5

SCORM for sure. (http://en.wikipedia.org/wiki/SCORM)

Polynuclear answered 20/10, 2008 at 11:38 Comment(0)
C
5

I absolutely hate it when someone doesn't use a naming convention. At where I worked, the lead developer (who I replaced) couldn't figure out if he wanted to use camelCase, or way_over_used_underscores. Personally, I hate the underscores and the camel case is easier to read, but it doesn't really matter as long as you keep to one standard.

PHP is especially bad at this, take a look at mysql_numrows which merges the two without the caps.

Custos answered 20/10, 2008 at 11:38 Comment(2)
In PHP, it helps with separation. mysql_numRows looks alot better than mysqlNumRows.Seeseebeck
@Seeseebeck And mysql_num_rows looks a lot better than mysql_numRows and mysql_nrows is the best.Predatory
W
5

In a large group at my company, we use C++ almost exclusively. Passing by non-const reference is forbidden.

If you want to modify a parameter to a function, you must pass it by pointer.

We have an internal flame war over the pros (easier to identify function calls that can modify variables) and cons (ridiculousness; having to deal with possible NULL pointers when you want a parameter to be required) about once a year.

Waterway answered 20/10, 2008 at 11:38 Comment(1)
Actually, I think it might not be such a bad practice. If only because programmers, in general, have to read code much more often than write it...Tact
S
5

Perhaps one of the more frustrating situations I've encountered was where people insisted on prefixing Stored Procedures with the prefix "sp_".

If you don't know why this is a bad thing to do, check out this blog entry here!

In a nutshell, if SQL Server is looking for a Stored Procedure with an sp_ prefix, it will check the master database first (which it won't find unless the SP is actually in the master database). Assuming it isn't in the master DB, SQL Server assumes the SP isn't in the cache and therefore recompiles it.

It may sound like a small thing, but it adds up in high volume or busy database server environments!

Streamy answered 20/10, 2008 at 11:38 Comment(1)
I didn't know that, but this convention annoys me just because it becomes impossible to jump anywhere in the long stored proc list. Everything starts with S.Agnesse
S
5

As I always worked self-employed/freelancer/project leader, I never got into someone's standards, all standards are my decisions. But, I recently found a fun piece of "coding standards document" back when I was 15:

All functions must be named "ProjectName_FunctionName".

Well, procedural PHP, anyone? Those weren't times of hard PHP OOP yet, but still. If I wanted to use code from one project to another, I would have to rewrite all references, etc.

I could have used something like "package_FunctionName".

Strengthen answered 20/10, 2008 at 11:38 Comment(0)
D
4

We're coding after MISRA standard. The ruleset has "MUST" and "CAN" parts, and we spent hours of discussing which rules we don't want to apply and why, when someday upper management said "We want to tell our customers we're 100% compliant. Tomorrow, we apply all."

Among the rules is one that says: No bit operations on signed data. Trying to find out what the rule is for, the explanation was presented: There is no guarantee about the bit representation of signed data. There is only 2s complement in the world, but the standard makes no guarantee!

Anyway, doesn't sound like a big thing - who wants to declare bitcoded variables as signed?

However, the holy rules checker interprets "integer promotion" as "promotion to signed" and the C standards guru says it has to be. And every bit operation does integer promotion. So instead of:

a &= ~(1 << i)

you have to write:

a = (unsigned int)(a & (unsigned int)~(unsigned int)(1 << i))

which is obviously much more readable and portable and all. Fortunately I found out that a shifted 1u stays unsigned. So you can reduce it to:

a = (unsigned int)(a & (unsigned int)~(1u << i))

Funnily, there is a rule that was not activated: Forbid using funny characters like '\' in #include. The DOS-corrupted folks won't believe that writing #include "bla/foo.h" does work even with every windows compiler and is much more portable.

Donough answered 20/10, 2008 at 11:38 Comment(1)
On a Swedish keyboard, entering '\' is harder than '/'. So when I'd noticed that one could write '/' instead of '\' almost everywhere I did not think twice.Tasimeter
A
4

The Project i work for hard coding is a strict NO..So we were forced to hash define as below

#define 1 ONE

Anastos answered 20/10, 2008 at 11:38 Comment(1)
<shudder>This is sooo bad.</shudder>Inquiry
P
4

On one of my first jobs the boss said that we should always use fully qualified type names in C# and forbid usings, since we should always know which type we're using when declaring variable, parameter, etc.

Polyzoan answered 20/10, 2008 at 11:38 Comment(0)
P
4

While coding for a VB project I was asked to add the following comment section for each of the methods

'Module Name
'Module Description
'Parameters and description of each parameter
'Called by
'Calls

While I found the rest quite alright but I was against the last two, the reason I argued was the as the project becomes large it will become difficult to maintain. If we are creating the library function then we can never be able to maintain Called by. We were small team of 6, so the argument made by manager was that since you are going to call the functions this should be maintained. Anyway I had to give up this argument as the manager was adamant. The result was as expected, as the project become larger no one cared to maintain Called by and Calls.

Peppermint answered 20/10, 2008 at 11:38 Comment(0)
P
4

Giving numbers to our tables, like tbl47_[some name]

Parterre answered 20/10, 2008 at 11:38 Comment(1)
Now its easy to tell when that table was added!Seeseebeck
S
4

I had to spell and grammar check my comments. They had to be complete sentences, properly capitalized and finished with a period.

Sherysherye answered 20/10, 2008 at 11:38 Comment(4)
I always enforce this rule. I suppose it's due to my belief if the broken windows theory (being sloppy in one place encourages people to be sloppy in other places).Seumas
@Sander: That's belief in the broken windows theory. (Sorry, couldn't resist the irony.)Cotta
Eww... when I want to read a comment I want something short and easy to read, not an English Paper paragraph.Seeseebeck
Spell check, sure, and reasonable grammar is a good thing. Makes it easier to read. But full sentences not (always) so much.Zins
I
4

I've been getting worked up over naming table columns after mysql keywords. It requires stupid column name escaping in every single query you write.

SELECT this, that, `key` FROM sometable WHERE such AND suchmore;

Just horrible.

Inflight answered 20/10, 2008 at 11:38 Comment(1)
SELECT this, that, key etc is an acceptable alternative, in my world anyway. I tend to quote names, but usually have to fix tablename.columnname with some regularity.Marrs
A
4

I worked in a VB .NET shop three years ago, where the "technical lead" decreed that all methods accepting a reference type parameter (i.e., an object) must use ByRef instead of ByVal. I found this especially odd because they'd asked me the ByVal/ByRef-what's-the-difference question in my interview, and I explained how it worked for value types and for reference types.

His explanation for the practice: "Some of the newer, less-experienced devs will get confused otherwise."

At the time, I was the most recently hired, and it was my first permanent .NET job. And I wasn't confused by it.

Agnesse answered 20/10, 2008 at 11:38 Comment(1)
Ugh. Now I'm seeing this in my current job too: Methods that use ref on parameters because the methods change properties of the reference type passed in, and the developer didn't understand how reference types work.Agnesse
G
4

In C++, we had to write explicitly everything that the compiler is supposed to write for us (default constructor, destructor, copy constructor, copy assignment operator) for every class. Looks like whoever wrote the standards was not very confident on the language.

Gibby answered 20/10, 2008 at 11:38 Comment(1)
Or the standard was written back in the days when compilers didn't do that reliably.Cribwork
M
4

I completly disagree with this one, but I was forced to follow it:

"All HTML LINKS will ALWAYS be underlined."

A while back I explained why I disagree on my blog.

Note: Even Stackoverflow ONLY underlines links when you move the mouse over them.

Mita answered 20/10, 2008 at 11:38 Comment(2)
Is there a reason you use "consistence" instead of "consistency?"Buckish
But this is the default in most browsers, so it's not likely to confuse anyone.Darra
A
3

at my previous job, which I gladly quit 3 months ago:

database:

  • Table names had to be uppercase.
  • Table names had to be prefixed TBL_
  • 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).
Alcantar answered 20/10, 2008 at 11:38 Comment(1)
Just thinking out loud, could "DS" be "Dynamic Strings"? In any case, this stuff is horrible.Gregson
C
3

Not being allowed to use Pointers or GOTO! (In C, none-the-less!) Thankfully this was merely a "software engineering" class, which I was able to graduate and then enter the "real world".

Chavannes answered 20/10, 2008 at 11:38 Comment(10)
Banning pointers is bad. Banning GOTO makes perfect sense. Shame on you for wanting to use goto.Steffens
It's C. C doesn't exactly have the glut of flow-control (exception handling, for example) that other higher-level langauges have. Sometimes GOTO makes for an elegant implementation in C.Chavannes
Labeled goto:s are OK, although usually avoidable. Most commonly you're doing too much in too few lines of code if you need goto:s for flow control. But then again it's C...Gregson
"C doesn't exactly have the glut of flow-control" what language? what glut? Please give some examples.Confessedly
SDX2000: Do you mean to ask for examples of flow control found in other languages but not in C? I've mentioned that the language is C.Chavannes
Well, It makes perfect sense to forbid such things; But did you just say that you were forbidden to do so in a programming lecture? What tha heck? When you are learning something it's meant that you really should burn your finger so that you have some experience. Probably the teacher was unsure about these himself..Tasimeter
The general philosophy at that place was that "Pointers and GOTO are evil". Nevermind that pointers aren't optional in C.Chavannes
Anybody who, in a modern language, just bluntly claims that goto is evil is an idiot. (No, I'm not calling Dijkstra an idiot. I just know the historical context of his article, something the anti-goto cult keeps forgetting -- and I'm being charitable here in assuming they ever actually knew.)Hermy
GOTO is just as evil as JMP in assembly. Sure you can use it badly (heck, using break and continue can make your control flow even uglier), but that doesn't mean it's always evil. I think GOTO should be taught as a useful but rarely needed tool.Zins
I was taught to use GOTO only for forward jumps. Never use it for backward jumps. Best teaching I've ever had.Neoplasty
W
3

No Hungarian whatsoever.

OK, you're thinking this is bad why? Well, because they considered this to be Hungarian:

int foo;
int *pFoo;
int **hFoo;

Now, any old-school Mac programmer will remember dealing with Handles and Ptrs. The above is the easiest way to tell them apart - Apple sample code is full of it, and Apple was hardly a hotbed of Hungarianism. And so when I had to write some old-school Mac code, naturally I did that, and got it shot down for being Hungarian.

But nobody could propose an alternate naming scheme that preserved the clarity of three variables referring to the same data in different ways, so I checked it in as-is.

Waterway answered 20/10, 2008 at 11:38 Comment(1)
How about: int foo; int *fooPtr; int **fooHdl; Now they even sort together!Childbirth
H
3

At a major UK bank I was brought in to act as a design authority on a new .NET system.

Their rules state that the database tables had to be a maximum of 8 characters long, with the project code (a 5 digit code) as the prefix.

They were enforcing old DB2 rules onto Windows projects sigh

Hillell answered 20/10, 2008 at 11:38 Comment(0)
C
3

Although this wasn't at a job, we had a massive project for a class in college. One of the requirements was commenting every line of code in our application -- regardless of what it did... and each line had to be specific e.g.

int x=0; //declare variable x and assign it to 0

We weren't allowed to do this:

int x, y, z = 0; //declare and assign to 0

As it wasn't detailed enough. And that's not even following the naming conventions forced upon us.

Needless to say we spent a few hours going back through the code...

Cordwainer answered 20/10, 2008 at 11:38 Comment(6)
Wow, and I thought that I taught an extreme CS 1 class... We had no 1 letter variable names (just in CS 1) and comments for "every logical chunk"Carbonation
Yea, it was pretty absurd considering it was an upper level class - especially one where you had to know what you were doing considering the nature of the project.Cordwainer
You're not assigning x to 0 there... you're assigning 0 to x.Inflight
@ Kris - you're very correct. I probably would have lost 10 points on that if I had turned it in >.<Cordwainer
I would have told my prof to go suck himself... probably explains why my grades aren't the best.Bioclimatology
In fact, you're not doing any assignment whatsoever there. That's an initialization, which is distinctly different from an assignment in both C and C++. 1000 points off!Onomatopoeia
S
3

At the place I'm currently working, the official coding standard stipulates a maximum line length of eighty characters. The rational was to enable hard-copies of the code to be formatted. Needless to say, this led to very odd code layout. I've worked to eliminate this standard, mainly through the argument of 'when was the last time you made a hard-copy of code?' Readability now versus chance of making a hard-copy on an eighty column DMP?

Skizz

Seguidilla answered 20/10, 2008 at 11:38 Comment(8)
This wasn't as bad when everyone used text terminals or 640x480 or 800x600 monitors and I frequently print out sections of code to review, but there is no need to make it a standard anymore. However, suggesting to keep it under 150 or so isn't bad practice.Societal
Lines too long? then you don't have enough monitors. My editor stretches across all three of my displays!Marrs
@TokenMacGuy: sweet! Then you can finally have the mythic perfect method: TheNewSuperClassObjectForTrainingFlightManagement myInstanceOfTheNewSuperClassObjectForTrainingFlightManagement = new TheNewSuperClassObjectForTrainingFlightManagement( TheNewSuperClassObjectForTrainingFlightManagementConfigurationOptionOne.FirstOption, TheNewSuperClassObjectForTrainingFlightManagementConfigurationOptionTwo.SecondOption); That only takes up 400 columns or so!Illuminating
with 16:9 and 16:10 monitors standard now this is really an idiotic requirement.Starofbethlehem
Except that we're dealing with the human eye here, and excessively wide columns aren't easy to read.Cotta
The old 80 character limit needs to be abolished in favor of 140. 80 is too small, and 140 is quite largeSeeseebeck
I think 80 columns makes sense for most code, but standards that force an 81 character line to be split is a bit much IMO. I had a job like that once and it was annoying (actually, our limit was 72). Most good code naturally fits in < 80 columns but there are times when going a few over makes the code more readable rather than less.Sherysherye
80 character is a very reasonable limit. The people who disagree probably edit in IDE's rather than terminals.Predatory
W
3

I ran into two rules that I really hated on a C job a few years ago:

  1. "One module per file," where "module" was defined as a C function.

  2. Function-local variables allowed only at the top of the function, so this sort of thing was illegal:

if (test)
{
   int i;
   ...
}
Waterway answered 20/10, 2008 at 11:38 Comment(6)
Those are both pretty horrible :)Carnify
The first rule actually makes sense for static libraries, where only the referenced objects will be linked in. Having one function per file avoids accidentally linking in unused functions.Baroja
In general, I like the second rule! especially in C where you can't declare just anywhere...Carbonation
In Delphi you can only declare function-local variables at the top. It structures your code, I don't think it is bad.Trepang
I've been bitten by bugs caused by #2 before. If you're declaring all local variables at the top, there's no scope restrictions for where it can be used or assigned. It's quite easy for a bug to slip in because a different variable was used rather than the one you really wanted (especially if you've copied, pasted and edited similar parts of the method). You might take a hit on structure, but declaring variables to the scope where they're used can prevent some bugs from even occurring.Slant
@Brian Postow Its a bit late, but that is correct C code because the declaration is at the top of a block, that is, the braces of the if statements.Predatory
M
3

Writing methods comments with pointless information for almost all methods.

Not allowing multiple exit points from a method.

Hungarian notation for all variables, enums, structures and even classes, e.g. iMyInt, tagMySturcture, eMyEnum and CMyClass.

Mcwhirter answered 20/10, 2008 at 11:38 Comment(3)
I kind of like single exit points... then again, I'm a paradigm purist...Carbonation
I always hated my CS (Java) requirements that all methods be fully commented, even something like int getX(){ return this.x; }Zins
Keeping single exit points makes perfect sense. I once had to fix a library that did my LPT port communication (couldn't be bothered to figure out how Windows did access to hardware), because it was badly leaking memory for each request. Turned out the author (probably) first made a general function template with malloc() and free() in it, and then (by omission?) added a second return point that directly returned the driver call's (which used the structure) result. Need I add that this new return point was inbetween allocation and freeing? shudderTripe
T
3

I implemented and modified an open-source asp classic shopping cart (that is mostly a long string of dailyWTF candidates,) that started every variable with a lower case p. As in, pTax_Amount or pFirst_Name.

There was no explanation for this, tho I read somewhere on one of their forums it was to avoid using reserved words like State - you'd have pState instead. They also append temp to things kinda randomly. like rsTemp, and connTemp. As opposed to the permanent record sets and database connections, I guess.

Tyro answered 20/10, 2008 at 11:38 Comment(1)
Reserved names maybe, but not for the entire codebaseSeeseebeck
R
3

The creator of the file (doesn't have to put any code in) has to put their name in the file. So if you create stubs or placeholders, you "own" them forever.

The guy who actually writes the code doesn't add his name; we had source control so that we'd know, always who to blame.

Ringlet answered 20/10, 2008 at 11:38 Comment(3)
Huh... not really sure how that'd ever be useful...Riddance
Did that have anything to do with holdovers from COBOL and the AUTHOR. clause in the IDENTIFICATION DIVISION.?Cotta
It's possible, although since the company was primary made hardware, I'd think Fortran was a more likely ancestor.Ringlet
P
3

We have a no code past the 80th character column that is controversial in our C++ development team. Liked and code review enforced by some; Despised by others.

Also, we have a very controversial C++ throw(), throw(...) specification standard. Religiously used by some and demonized by others. Both camps cite discussions and experts to enforce their respective positions.

Pierette answered 20/10, 2008 at 11:38 Comment(6)
We don't religiously enforce the 80 character limit, but it's a good guideline and most of us like it. It's not in our (barely existant) coding standards, just something we have agreed on. If you ever end up looking at code in a terminal window it's nice not to have to resize it.Costrel
When's the last time you looked at code in a terminal window? I just expand my terminal if I have to, or use the -S flag to less, or just open the code in my favourite syntax-hilighting editor. Sheesh.Scurlock
Quite often actually, and yes of course I can expand my terminal if I have to, or any of the other options, but I'd rather not have to.Costrel
Also, if you stick to 80 columns you can easily have two windows side-by-side on screen. You don't have to stick religiously to 80 columns for that to be true, but anything over about 100 columns and you can't, with sensible sized fonts on a 1600x1200 screen.Costrel
+1 for two windows side by side :) I tend to have two consoles stacked on the left and my editor to the right.Riebling
an 80 char limit is sensible, but there are times when it should be broken. Not very many, though.Zins
K
3

The strangest was that type qualified variable naming must be used in Java, and the types where those of the columns from the database. So a java.sql.ResultSet had to be called tblClient etc.

Kalk answered 20/10, 2008 at 11:38 Comment(0)
S
3

Anything having to do with formatting (especially place of '{' and other block character) is always a pain to enforce.

Even with an automatic format at each source file checking, you can not be sure every developer will ever always use the same formatter, with the same formatting set of rules...

And then you have to merge those files back to trunk. And you commit suicide ;)

Swanherd answered 20/10, 2008 at 11:38 Comment(2)
Note: the location of the { matters in Javascript :-(Endosmosis
@Frew: that would mean the location of curly brackets have to be enforced consistently by every developer. That would not be harmful for merges.Swanherd
B
2

Our old c# coding standards required that we use huge, ugly comment blocks. You know in Code Complete where Steve McConnell gives a prime example of an ugly comment macro? That. Almost an exact match.

The worst thing about this was that c# is a language that already has good (and relatively unobtrusive) comment support.

You'd get something like this:

/// <summary>
/// Add an item to the collection
/// </summary>
/// <parameter name="item">The item to add</parameter>
/// <returns>Whether the addition succeeded</returns>
public bool Add(int item) { ... }

and it'd turn into this:

// ########################################################## //
/// <summary>
///     Add an item to the collection
/// </summary>
///     IN:  <parameter name="item">The item to add</parameter>
///     OUT: <returns>Whether the addition succeeded</returns>
// ########################################################## //

Note that StackOverflow's syntax highlighting does not do it justice, as with the default VS text scheme, the # symbol is bright green, resulting in an overpowering violation of your retinas.

I can only assume the authors were really, really fond of it from previous endeavours with C/C++. The problem was that, even if you just had a couple of auto properties, it'd take up about 50% of your screen space and add significant noise. The extra // lines also messed up R#'s refactoring support.

After we ditched the comment macro, we ended up spanking the whole codebase with a script that took us back to visual studio's default c# comment style.

Billposter answered 20/10, 2008 at 11:38 Comment(3)
Were the people who wrote your coding standard not aware of the block comment delimiters that C-style languages have?Schoolbag
I'm not sure that I'd classify a comment convention that inlines pseudo-HTML as "unobtrusive" -- relatively or not. Indeed I'd probably classify such a commenting convention as "fugly".Hermy
It doesn't offend my eyes or distract me when I'm reading code and it has excellent IDE support, so that's good enough for me.Billposter
S
2

having to put m_ prefix on java instance variables and g_ prefix on java static variables, most un-Java idiot cruft I have ever had to deal with, perpetuated by C and C++ developers that didn't know how to use anything other than notepad to develop Java with!

except that nobody actually followed this except to put m_ on everything even statics even method names ...

Serdab answered 20/10, 2008 at 11:38 Comment(0)
A
2

The worst is a nameless place I still earn money from, there are no standards. Every program is new adventure.

Fortunately another contractor and I are slowly training the real employees and forcing some structure on the mess.

Amalgam answered 20/10, 2008 at 11:38 Comment(0)
R
2

Only one variable can be declared per logical line. [Rationale: Multiple declarations per line results in an inaccurate line-of-code count.]

Rosemaryrosemond answered 20/10, 2008 at 11:38 Comment(2)
facepalm That's amazingly inane. Condolences!Marrs
The rule itself isn't that bad, at least in some languages. It's a decent rule for C++, for example. Most of my declarations are one to a line. The rationale, on the other hand, is amazingly stupid.Cotta
B
2

All documents in my company are version-controlled. So far, so good.

But for EVERY single file, upon first committing to CVS, you must immediately add two tags to it: CRE (for CREation) and DEV001 (for 1st DEVelopment cycle). As if it being the first version of the file itself wasn't enough.

After that, the process gets a bit more reasonable, fortunately.

Brottman answered 20/10, 2008 at 11:38 Comment(0)
A
2

I am not allowed to use this-> to reference local variables in our c++ code...

Annabell answered 20/10, 2008 at 11:38 Comment(3)
Maybe you mean member variables? BTW, my company does not like this either.Perissodactyl
Oops, yes that is indeed what I meant. What reasons are you given? I just a "I don't like it" during code-reviews.Annabell
I think the reason behind this rule is to avoid having arguments and local variables with the same name as members.Lease
D
2

All file names must be in lower case...

Dealfish answered 20/10, 2008 at 11:38 Comment(4)
That's not unreasonable if the code is supposed to be cross-platform and any of the targets is case-sensitive. It's easier to pick a case and stick with it, and at least THEY DIDN'T PICK ALL CAPS.Commandment
I agree with Just Some Guy. And here's another such standard I like: NO spaces in file or directory names! (If you must, substitute the underscore or period...)Stocking
It is unreasonable if you are coding Java and the filename has to match the class name.Theirs
OK, that's a pretty reasonable case for overriding the rule.Commandment
J
1

The worst coding standard I've ever had to live with was insane indentation.

The code had originally been written on a mainframe using 60x80 character green-screen terminals (this was quite a long time ago). The default tab size on these things was 8 characters, but the programmers at the time decided that was too big - the screen itself only showed 80 characters across, so an 8-character tab wasted a lot of space.

So they decided to set the intent size for their code to 4 characters.

All fair enough, you say. Except that they didn't do it by changing the tab size. They did it by making the first indentation to be 4 spaces, the second one to be a single tab character, and so on alternating between adding 4 spaces and a tab character.

While they stuck to the green screen terminals, this was fine. Weird, but fine.

The real chaos began when the development team got their shiny new Windows PCs.

The PC editor they chose had its tab size set to 4 characters, and so when the code was loaded, the indentation was simply all over the place.

We couldn't fix the indentation because some devs were still using the green screens, so for the year or so that it took to get the entire team transitioned to PCs, we had an absolute nightmare trying to work with code that was virtually unreadable in either one environment or the other (or more frequently, both).

Jumbuck answered 20/10, 2008 at 11:38 Comment(4)
If a tab character was guaranteed to take up 8 spaces on the green screens, were you not able to simply replace all tabs with 8 spaces using a find-replace operation, and then change the PC editor settings such that pressing tab would insert 4 spaces rather than a tab character?Schoolbag
@JAB: tabs move the cursor to the next tab position, so any given tab character could represent any number of spaces up to 8, so search+replace wasn't that easy. And we did try to fix it, but the people still using terminals couldn't change their editors, so the problems kept coming back.Jumbuck
Ah, so the terminal editors couldn't have their settings changed.Schoolbag
@Schoolbag - exactly. it was quite a locked down environment.Jumbuck
H
1

Strangest was "this must be coded in C++". Presumably I'm being hired for my expertise. If my expert opinion says another language would do the job better, then that other language should be the one used. Telling me which tool I should use is about the same as telling an automobile mechanic that he's only allowed to use metric wrenches. And only wrenches.

Hermy answered 20/10, 2008 at 11:38 Comment(4)
I don't know what project you were working on, but maybe there is an external restriction or maybe they have other people working with something other that is needed to be able to use your thing from C++.Tasimeter
@Frank: Part of my presumed expertise is knowing what the use case scenarios are. If there was some need to interact with others using C++ I'd either pick C++ or make some good, transparent C++ bridges if the effort was worth it. Again, having a manager with little to no coding experience make these decisions is just plain wrong. In most cases (as it was in this case) it's just a manager hearing that C++ is the latest/greatest that determined the choice of language. To the detriment of the product.Hermy
There are so many valid reasons for asking this! What if for example, the company already has support staff or/other developers who already know and support C++ applications?Elizabetelizabeth
@corydoras: I say again: Part of my presumed expertise is knowing what the use case scenarios are. If there was some need to interact with others using C++ I'd either pick C++ or make some good, transparent C++ bridges if the effort was worth it. Again, having a manager with little to no coding experience make these decisions is just plain wrong. In most cases (as it was in this case) it's just a manager hearing that C++ is the latest/greatest that determined the choice of language. To the detriment of the product. Is that clearer?Hermy
E
1

Capitalizing Acronyms

DO capitalize both characters of two-character acronyms except the first word of a camel-cased identifier.

System.IO
public void StartIO(Stream ioStream)

DO capitalize only the first character of acronyms with three or more characters except the first word of a camel-cased identifier.

System.Xml
public void ProcessHtmlTag(string htmlTag)

DO NOT capitalize any of the characters of any acronyms, whatever their length, at the beginning of a camel-cased identifier.

Eightieth answered 20/10, 2008 at 11:38 Comment(4)
Fair use (I'm poking fun) -- "Framework Design Guidelines", Cwalina and AbramsEightieth
By the way, one of the projects I'm on does check for this using "FxCop". I get a lot of warnings about naming conventions, so I wouldn't know if I got any important warnings. My component is not part of any customer-facing "framework".Eightieth
Well, I don't know about how I should feel about this. I do often mistakenly type document.getElementByID instead of document.getElementById (notice the capitalization of the last D) but ID is NOT an acronym.Tasimeter
I would regard "ID", uppercase, as the proper spelling for an identification document, or any modern linguistic usages derived from that. I dislike "Id" as a spelling.Dessau
D
1

My old boss insisted that we use constants instead of enums but never gave a reason and in all the scenarios these were used an enum made more sense.

The better one though was insisting that all table names be singular and then making the classes in code singular as well. But not only did they represent the object, such as a user or group, they also represented the table and contained all of the CRUD for that table and numerous other actions. But wait, there’s more! They also had to contain a publicly visible name/value collection so that way you could get the properties with an indexer, by column name, just in case you added a new column but didn't want to add in a new property. There were a bunch of other "must do's" that not only didn't make sense, but put a big performance hit on the code as well. I could try to point them all out but the code speaks for itself and sadly this is almost an exact copy of the User class I just pulled out of an old archive folder:

public class Record
{
    private string tablename;
    private Database database;

    public NameValueCollection Fields;

    public Record(string TableName) : this(TableName, null) { }
    public Record(string TableName, Database db)
    {
        tablename = TableName;
        database = db;
    }

    public string TableName
    {
        get { return tablename; }
    }

    public ulong ID
    {
        get { return GetULong("ID"); }
        set { Fields["ID"] = value.ToString(); }

    }

    public virtual ulong GetULong(string field)
    {
        try { return ulong.Parse(this[field]); }
        catch(Exception) { return 0; }
    }

    public virtual bool Change()
    {
        InitializeDB(); // opens the connection
        // loop over the Fields object and build an update query
        DisposeDB(); // closes the connection
        // return the status
    }

    public virtual bool Create()
    {
        // works almost just like the Change method
    }

    public virtual bool Read()
    {
        InitializeDB(); // opens the connection
        // use the value of the ID property to build a select query
        // populate the Fields collection with the columns/values if the read was successful
        DisposeDB(); // closes the connection
        // return the status    
    }
}

public class User
{
    public User() : base("User") { }
    public User(Database db) : base("User", db) { }

    public string Username
    {
        get { return Fields["Username"]; }
        set
        {
            Fields["Username"] = value.ToString(); // yes, there really is a redundant ToString call
        }
    }
}

sorry if this double posts, first time around I might not of been human or maybe the site just has a limit to how bad code can be to be posted

Deery answered 20/10, 2008 at 11:38 Comment(1)
singular table names are good Relation Database design tenents and go back to the beginning of RDBMS times. Now the properties dictionary really is a WTF. And this is a bastardization of the "ActiveRecord" pattern that has been proven NOT to scale.Starofbethlehem
P
1

In my last job, my supervisor always enforced Murphy's Law:

"Anything that can go wrong will go wrong."

I guess it was so we didn't slack off doing some quick fixes in the code or something like that. And now I constantly have that phrase in my head.

Pantie answered 20/10, 2008 at 11:38 Comment(2)
Why is this a strange at all?Confessedly
@SDX2000 hahaha you're right, it isn't strange at all.Pantie
D
1

The first language I used professionally was 4D. It supported interprocess variables prefixed by a <>, process variables with no prefixes and local variables which started with a $. All those prefixes (or lack thereof) are used by the compiler/interpreter to determine the variable's scope.

The actual strange coding standard was some sort of hungarian notation. The catch was that instead of naming variables based on their types, they had to be prefixed according to their scope.

Variables, whose scope were determined by their prefix, had to be prefixed with redundant information!

I don't dare ask the guy responsible for the standards why it had to be this way...

Drona answered 20/10, 2008 at 11:38 Comment(0)
U
1

Back in my COBOL days, we had to use three asterisks for comments (COBOL requires only one asterisk in column 7). We even had a pre-compiler that checked for this, and wouldn't compile your program if you used anything but three asterisks.

Unanimity answered 20/10, 2008 at 11:38 Comment(0)
H
1

Use _ or m_ in front of global variable when you can simply use the keyword this. when you need to access global variable...

Haldes answered 20/10, 2008 at 11:38 Comment(9)
Uh? Isn't "m_" more commonly used to identify members, not globals?Barogram
Do not know, not me that enforce that! m_ for module... module... class.. I can't tell you more :PHaldes
This is part of "How to write unmaintainable code" -- you can use m_ for module, member, and method.Parhelion
_ for private instance member isn't bad...m_ irks me though.Monoceros
I use m_ for all variables, functions, modules and filenames it means "mine"!Mata
I've grown fond of _varName for private class variables, VarName for accessors, and varName for function parameters and local variables. It gives me a quick visual identifier as to scope.Piscatory
the catch, I think, is that the compiler will enforce the use of "m_" (or whatever other prefix you choose), but the "this->" is optional, and so might be overlooked.Vannavannatta
+1. Great arguments, guys! Where were you when I asked precisely that question ? ;-) #133277Swanherd
I don't use leading underscores. They're safe provided they're followed by lowercase letters and in some sort of class or namespace, but it seems easier just to avoid them.Cotta
E
0

"The guys who wrote the compiler are probably a lot smarter than you so don't try something clever" is what one guide line document said (not quite literally).

Elissaelita answered 20/10, 2008 at 11:38 Comment(2)
This sounds perfectly reasonable to me. In this context, "something clever" refers to premature and misguided attempts at optimization that either make the program run even slower (by confusing the compiler's optimizer) or thoroughly obfuscate the code for a minuscule performance enhancement.Onomatopoeia
you mean attempted minuscule performance enhancement. "clever optimizations" could actually end up being slower :)Airscrew
R
0

Postfixing _ to member variables. e.g.

int numberofCycles_;

This was in C++ on an open source project with a couple of developers. The main side effect was not knowing that a variable had class scope until getting to the end of the name. Not something I had thought much about before, but clearly backwards.

Radiochemical answered 20/10, 2008 at 11:38 Comment(2)
I'm unconvinced by the need to distinguish member variables at all, but if you're going to the beginning is obviously the place for it.Costrel
names beginning with _ are reserved for the implementation. trailing underscore is a convention popular in the STL.Forging

© 2022 - 2024 — McMap. All rights reserved.