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

243,219

Solution 1

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

Solution 2

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

Solution 3

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.

Solution 4

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.

Solution 5

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.

Share:
243,219

Related videos on Youtube

Brian R. Bondy
Author by

Brian R. Bondy

About me: Founder and lead developer for Brave Software, working on the Brave browser. Formerly a Khan Academy software engineer Mozillian (Mozilla contributor) C++, JavaScript, C, C#, Python, programming for &gt; 20 years Graduate of the University of Waterloo; Married with twins boys, one singleton, and a red tri-colored border collie Past Microsoft MVP for Visual C++ Contributor to various other open source projects like WikiMedia Links: Blog/Personal website; Twitter: @brianbondy; Here is a picture of my pet unicorn:

Updated on January 19, 2020

Comments

  • Brian R. Bondy
    Brian R. Bondy about 4 years

    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.

    • matt b
      matt b over 15 years
      After reading thru this list suddenly I feel like I've had a very lucky career to avoid any of this forced standard crap!
    • JasonFruit
      JasonFruit about 14 years
      And I'm embarrassed to admit that very early in my career, I imposed one of the answers on a team. I'm so sorry, guys.
  • E_the_Shy
    E_the_Shy over 15 years
    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"
  • Brian R. Bondy
    Brian R. Bondy over 15 years
    By everyone, your boss means himself.
  • Rik
    Rik over 15 years
    Yeah, magic is hard to maintain, appearantly ;) LOL, though.
  • nickf
    nickf over 15 years
    yuckers. This is patently the worst bracketing style ever.
  • John Rudy
    John Rudy over 15 years
    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 ...
  • John Rudy
    John Rudy over 15 years
    I used to fall into this camp ... But grew out of it, and have learned to love the conditional operator (when it's appropriate).
  • John Rudy
    John Rudy over 15 years
    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!
  • Anthony Fammartino
    Anthony Fammartino over 15 years
    ps. The silly 'reason' was so that it would be easier for people to transfer context from C to Java and vice-versa.
  • Kirk Strauser
    Kirk Strauser over 15 years
    Well, at that point you might as well give up, right?
  • Kirk Strauser
    Kirk Strauser over 15 years
    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.
  • Jeffrey L Whitledge
    Jeffrey L Whitledge over 15 years
    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.")
  • Mark Baker
    Mark Baker over 15 years
    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.
  • Mark Baker
    Mark Baker over 15 years
    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.
  • Richard T
    Richard T over 15 years
    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 -.
  • Richard T
    Richard T over 15 years
    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...)
  • Guido
    Guido over 15 years
    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.
  • chills42
    chills42 over 15 years
    I really hate that... there's a few people who do that here (it's not a standard or anything though)
  • Bobby Jack
    Bobby Jack over 15 years
    Looks like Whitesmiths style which was used in the original 'Programming Windows' by Petzold - go figure! ;)
  • Bobby Jack
    Bobby Jack over 15 years
    If anything, the rule should be "always use the ternary operator", an operator of pure beauty :)
  • Bill K
    Bill K over 15 years
    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.
  • Marc Bernier
    Marc Bernier over 15 years
    Workaround: if (!Initialize()) { RetVal=ERR_BADINIT; goto ReturnPoint; } (lots more code) ReturnPoint: return RetVal; } Problem solved! ;)
  • pmlarocque
    pmlarocque over 15 years
    adding 'ref string sError' to every single function, that best practice they show in computer science 101 at my university!
  • gbjbaanb
    gbjbaanb over 15 years
    for 'magic' read performance killing unmaintainable obscure nightmare code. He's right.
  • gbjbaanb
    gbjbaanb over 15 years
    see children, look what happens if you don't play nicely with others :-)
  • matt b
    matt b over 15 years
    God I hate those types of comments - all they do is add visual litter to the screen
  • vitule
    vitule over 15 years
    buttonNameUnderscoreClick()
  • Martin Beckett
    Martin Beckett over 15 years
    Prefixing globals with 'g' is simpler than putting a "here be dragons" comment on every fucntion.
  • paercebal
    paercebal over 15 years
    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 ...
  • steffenj
    steffenj over 15 years
    Using one exit point should be encouraged, but certainly NOT being enforced. Especially if you consider early-out conditions.
  • Mitkins
    Mitkins over 15 years
    One test per 8 lines is actually not very many at all... Do you mean you can have AT MOST 165 tests?
  • John Rudy
    John Rudy over 15 years
    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 ... )
  • John Rudy
    John Rudy over 15 years
    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!
  • Craig
    Craig over 15 years
    My experience is Oracle people like to do things like this.
  • Craig
    Craig over 15 years
    Sounds like a rule developed pre source control. Or due to programmers only checking in once a week.
  • Robert P
    Robert P over 15 years
    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.
  • Robert P
    Robert P over 15 years
    Well->maybe_he_was(tired_of, exceptionally_long_underscore_names, and_so_banned, them_from_use);
  • moffdub
    moffdub over 15 years
    I avoid using reflection for major parts of design, but an outright ban is silly.
  • Jonathan Leffler
    Jonathan Leffler over 15 years
    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, ...
  • ojrac
    ojrac over 15 years
    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.)
  • Aidos
    Aidos over 15 years
    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...
  • wnoise
    wnoise over 15 years
    Yes, the two spacers should have given in.
  • JimDaniel
    JimDaniel over 15 years
    Maybe you mean member variables? BTW, my company does not like this either.
  • Hans
    Hans over 15 years
    Oops, yes that is indeed what I meant. What reasons are you given? I just a "I don't like it" during code-reviews.
  • pookleblinky
    pookleblinky over 15 years
    "When I was your age, we only had 2 characters! And it was case-insensitive!"
  • CodingWithSpike
    CodingWithSpike over 15 years
    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 :)
  • David Arno
    David Arno over 15 years
    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.
  • matt b
    matt b over 15 years
    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.
  • NotMe
    NotMe over 15 years
    Simply put multiple returns increase testing complexity. Further it increases the likelihood that you've done something wrong
  • NotMe
    NotMe over 15 years
    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.
  • NotMe
    NotMe over 15 years
    With all that and NASA still couldn't figure out whether to calculate in kilometers or miles...
  • Jonathan Leffler
    Jonathan Leffler over 15 years
    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.
  • Raj
    Raj over 15 years
    Thats why tab identation is so great. Everyone can change the size in his editor ;)
  • Kirk Strauser
    Kirk Strauser over 15 years
    OK, that's a pretty reasonable case for overriding the rule.
  • Kirk Strauser
    Kirk Strauser over 15 years
    I am sorry, so terribly sorry...
  • Kirk Strauser
    Kirk Strauser over 15 years
    No kidding. I bet it took forever to go through and remove all those SQL injections. ;-)
  • moffdub
    moffdub over 15 years
    I failed to mention that our IDE has a menu item titled "Generate Getters and Setters..."
  • Paulius
    Paulius over 15 years
    Building unmaintainable code for the future
  • Steve Jessop
    Steve Jessop over 15 years
    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.
  • Chris Vest
    Chris Vest over 15 years
    "50 possible identifiers ought to be enough for anyone" :p
  • Chris Vest
    Chris Vest over 15 years
    my preference: ... from customer left join address on (address.id = customer.address_id)
  • Chris Vest
    Chris Vest over 15 years
    sounds like someone was missing an algebraic Maybe type.
  • TonJ
    TonJ over 15 years
    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);
  • MagicKat
    MagicKat over 15 years
    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.
  • Manuel Ferreria
    Manuel Ferreria over 15 years
    That is pure evilness. I am sure your boss/TL is an overlord just waiting for his opportunity.
  • Alan Hensel
    Alan Hensel over 15 years
    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.
  • Deepak Battu
    Deepak Battu over 15 years
    I hope you didn't use any software from GNU = "GNU is Not Unix".
  • T.E.D.
    T.E.D. over 15 years
    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.
  • Jacob
    Jacob over 15 years
    I would say, that is pretty strange.
  • andriy
    andriy over 15 years
    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.
  • andriy
    andriy over 15 years
    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.
  • andriy
    andriy over 15 years
    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.
  • Anthony Fammartino
    Anthony Fammartino over 15 years
    @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.
  • Tim
    Tim over 15 years
    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?
  • Tim
    Tim over 15 years
    HRESULTS are useless unless you are using COM. It is not a good idea to force that paradigm on better practices. UGH!
  • Tim
    Tim over 15 years
    multiple returns (except for an initial error check) are the sign of poor programming and made code very complicated very quickly.
  • Jeromy Irvine
    Jeromy Irvine over 15 years
    @Czimi: I forgot to mention that. Every table has a field called FI_ID used as the primary key.
  • Daniel Rikowski
    Daniel Rikowski over 15 years
    Actually he is pretty nice in person and a good business man, but one would never know from these coding rules... :)
  • Daniel Rikowski
    Daniel Rikowski over 15 years
    Of course! Developers are supposed to write code, not waste time writing comments :)
  • Andreas Magnusson
    Andreas Magnusson over 15 years
    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.
  • Sergey Skoblikov
    Sergey Skoblikov over 15 years
    Holy sh... The T_guy who invented this nightmare should be killed with a F_gun and sent to TSX_hell.
  • Tetha
    Tetha over 15 years
    in that case, write yourself a script "Generate Getter- and SetterTests".
  • Tetha
    Tetha over 15 years
    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)
  • causa prima
    causa prima over 15 years
    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.
  • causa prima
    causa prima over 15 years
    Pookleblinky--there really were systems with those rules. The second computer I ever worked with.
  • causa prima
    causa prima over 15 years
    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!
  • causa prima
    causa prima over 15 years
    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)
  • causa prima
    causa prima over 15 years
    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.)
  • causa prima
    causa prima over 15 years
    You can set the indent in the environment options!
  • causa prima
    causa prima over 15 years
    I'm not too happy with i and never use it. Sometimes x, y and perhaps even z make excellent sense, though.
  • James Curran
    James Curran over 15 years
    @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)
  • Atario
    Atario over 15 years
    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.
  • Ashwin
    Ashwin over 15 years
    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.
  • Ashwin
    Ashwin over 15 years
    rofl .. writing fortran in C.
  • CodeIT
    CodeIT over 15 years
    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!
  • hasen
    hasen over 15 years
    omg, who the hell would come up with rules like this??? most importantly: how the hell does your team manage to code??
  • user1925801
    user1925801 over 15 years
    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.
  • user1925801
    user1925801 over 15 years
    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...
  • annakata
    annakata over 15 years
    burying queries in compiled code is such a pain, I'm 100% behind 100% sprocs policy for the abstraction alone
  • Lance Fisher
    Lance Fisher over 15 years
    Your choice: multiple returns or more nested if statements. I'll take multiple returns.
  • yuriks
    yuriks over 15 years
    And pretty much all of the C++ standard library.
  • Victor Stanciu
    Victor Stanciu about 15 years
    +1 for working with programmers that are afraid of OO
  • recursive9
    recursive9 about 15 years
    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 ;-)
  • Prasanth Kumar
    Prasanth Kumar about 15 years
    What happens if you have 164? 166?
  • Brian Postow
    Brian Postow about 15 years
    I really like the g, and m prefixes... I and O seem a bit weird...
  • John MacIntyre
    John MacIntyre about 15 years
    That sucks, but at least there was a reason for it.
  • Kostis
    Kostis about 15 years
    I can think of no better way of allowing people to discover who they would respectively dread either working for, or having work for them. You guys are on my list, feel free to put me on yours. :)
  • B Bulfin
    B Bulfin about 15 years
    More like 6 lines.
  • MbaiMburu
    MbaiMburu about 15 years
    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.
  • starblue
    starblue about 15 years
    Three cheers for capitalism!
  • joh6nn
    joh6nn about 15 years
    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.
  • tuinstoel
    tuinstoel about 15 years
    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.
  • tuinstoel
    tuinstoel about 15 years
    Well, Linus has stated that C++ is a horrible language: thread.gmane.org/gmane.comp.version-control.git/57643/…
  • Dineshkumar
    Dineshkumar about 15 years
    Yay for survival of the fittest...this guy didn't deserve to be running his own software business.
  • ShockwaveNN
    ShockwaveNN about 15 years
    Porcupine Tree are awesome! :)
  • tuinstoel
    tuinstoel about 15 years
    Who me? I can tolerate the porcupine trees but to say that I like them... no, not really. Or do you mean someone else?
  • ShockwaveNN
    ShockwaveNN about 15 years
    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.
  • Robert P
    Robert P about 15 years
    ...and that never works. :P
  • Rune Jeppesen
    Rune Jeppesen almost 15 years
    Shouldn't the setters and constructors be checking to make sure their inputs are legal and it leaves the object in a valid state?
  • T.E.D.
    T.E.D. almost 15 years
    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.
  • configurator
    configurator almost 15 years
    We had tbl and fld for all fields and tables. Completely useless...
  • thomasrutter
    thomasrutter almost 15 years
    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.
  • moffdub
    moffdub almost 15 years
    Of course not! "The database does that." (actual quote from co-worker)
  • Frew Schmidt
    Frew Schmidt almost 15 years
    Note: the location of the { matters in Javascript :-(
  • VonC
    VonC almost 15 years
    @Frew: that would mean the location of curly brackets have to be enforced consistently by every developer. That would not be harmful for merges.
  • Mr. Shickadance
    Mr. Shickadance almost 15 years
    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.
  • Mr. Shickadance
    Mr. Shickadance almost 15 years
    Wasn't there an old shell that was written entirely like this? Basically to the point where it didn't even resemble C.
  • Mr. Shickadance
    Mr. Shickadance almost 15 years
    The last sentence was great. How could someone be taken seriously when they make decisions like this?
  • Mr. Shickadance
    Mr. Shickadance almost 15 years
    The last one about the psychopath would get some people killed almost immediately.
  • paercebal
    paercebal almost 15 years
    @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... ^_^ ...
  • ASk
    ASk almost 15 years
    names beginning with _ are reserved for the implementation. trailing underscore is a convention popular in the STL.
  • David Thornley
    David Thornley almost 15 years
    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?
  • TGnat
    TGnat over 14 years
    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.
  • Greg D
    Greg D over 14 years
    Yeah! And comments make the build slower!
  • muusbolla
    muusbolla over 14 years
    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.
  • Sander
    Sander over 14 years
    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).
  • paercebal
    paercebal over 14 years
    @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.
  • Nick Dandoulakis
    Nick Dandoulakis over 14 years
    Steven, this reminds me the monkey experiment story :o) freekvermeulen.blogspot.com/2008/08/…
  • Steven A. Lowe
    Steven A. Lowe over 14 years
    @[Nick D]: yes, me too - hence the code-name "CodeMonkey" ;-)
  • 7wp
    7wp over 14 years
    It baffles me how such people even get hired????
  • Tyler McHenry
    Tyler McHenry over 14 years
    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.
  • Tyler McHenry
    Tyler McHenry over 14 years
    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.
  • Tyler McHenry
    Tyler McHenry over 14 years
    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!
  • causa prima
    causa prima over 14 years
    I can understand the begin/end stuff--{} look too much like ()!
  • T.E.D.
    T.E.D. over 14 years
    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.
  • MathGladiator
    MathGladiator over 14 years
    I recommend to people with indenting problems to statistically determine the original authors tab indention and replace it with tabs. Works surprisingly well.
  • Dave
    Dave over 14 years
    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)
  • João Portela
    João Portela over 14 years
    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' ;)
  • foraidt
    foraidt over 14 years
    That's how I came to love AccuRev's option to "Ignore Whitespace" when diffing. Simply awesome.
  • topski
    topski over 14 years
    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)
  • Daniel Rikowski
    Daniel Rikowski over 14 years
    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...
  • David Thornley
    David Thornley over 14 years
    @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.
  • David Thornley
    David Thornley over 14 years
    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.
  • David Thornley
    David Thornley over 14 years
    @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.
  • David Thornley
    David Thornley over 14 years
    @Sander: That's belief in the broken windows theory. (Sorry, couldn't resist the irony.)
  • Corey Porter
    Corey Porter over 14 years
    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.)
  • PaulMcG
    PaulMcG over 14 years
    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!
  • L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳
    L̲̳o̲̳̳n̲̳̳g̲̳̳p̲̳o̲̳̳k̲̳̳e̲̳̳ over 14 years
    I imagine your dev team must be masters of reverse engineering
  • Brent Bradburn
    Brent Bradburn over 14 years
    Fair use (I'm poking fun) -- "Framework Design Guidelines", Cwalina and Abrams
  • Brent Bradburn
    Brent Bradburn over 14 years
    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".
  • tuinstoel
    tuinstoel over 14 years
    3 seems like a fine decision to me but maybe I'm just one of those wimpy Europeans who likes compromises too much.
  • David Thornley
    David Thornley over 14 years
    Heck, the BASIC interpreters we worked with a long time ago had two-character variable names. Why complain about 5?
  • andriy
    andriy over 14 years
    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.
  • Michael Burr
    Michael Burr over 14 years
    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.
  • ZJR
    ZJR about 14 years
    Down with those wizards!! Always around, with their magic, stealing our jobs, seducing our women and corrupting our childrens!
  • ErikE
    ErikE about 14 years
    I just barfed in my mouth a little.
  • BlueRaja - Danny Pflughoeft
    BlueRaja - Danny Pflughoeft about 14 years
    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 stackoverflow.com/questions/36707/…
  • Behrooz
    Behrooz about 14 years
    maybe (((a)[(i)]).x) += (((((b)[(i)]).y) + (d)) - (7)); ?
  • Saurabh
    Saurabh about 14 years
    Actually I'd quite like to work for a company that eschews OO, just to get a break from working with OO zealots (the kind who think up some of the other stupid standards mentioned in this thread.)
  • JBRWilkinson
    JBRWilkinson about 14 years
    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).
  • JBRWilkinson
    JBRWilkinson about 14 years
    OMG! Don't most IDE text editors do curly-brace highlighting/matching now?
  • JBRWilkinson
    JBRWilkinson about 14 years
    What's with the phrase 'here be dragons'? I've seen that at multiple companies - where is it from?
  • ShockwaveNN
    ShockwaveNN about 14 years
  • JBRWilkinson
    JBRWilkinson about 14 years
    The OP is talking about putting the table name after 'ID', which is just weird.
  • ZJR
    ZJR about 14 years
    +1 'cause now I fancy a drink too!
  • Vinz
    Vinz about 14 years
    Does this imply it's forbidden to throw exceptions too? Throwing an exception can also be seen as a return point...
  • CMircea
    CMircea almost 14 years
    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?)
  • ConcernedOfTunbridgeWells
    ConcernedOfTunbridgeWells almost 14 years
    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.
  • Tim
    Tim almost 14 years
    @ConcernedOfTunbridgeWells Why in the world would you EVER need to search the code for an iterator variable? Good practice? Not likely.
  • intuited
    intuited almost 14 years
    @paercebal: En générale, c'est correctement écrit, sauf que quelques petits erreurs: «squatch»: ça doit être «squash»; «this one day»: en ce context-là, on dirait «that day»; «stocked procedures»: «stock procedures»; «chocked» s'écrit «choked». Aussi, dans les commentaires, vous utilisez °mentionned», ce qui doit être «mentioned» Mais vraiment, tout ça ne justifie pas une telle plainte. Au contraire, vous y montrez une excellente maîtrise de l'anglais; félicitations!
  • abelenky
    abelenky almost 14 years
    Banning pointers is bad. Banning GOTO makes perfect sense. Shame on you for wanting to use goto.
  • Thomas Eding
    Thomas Eding almost 14 years
    How do numbered local variable names solve the problem? You still have the same number of identifiers... only relabelled. I don't get it.
  • Arafangion
    Arafangion almost 14 years
    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.
  • Daniel Rikowski
    Daniel Rikowski almost 14 years
    @trinithis: It's the number of unique identifiers which is limited.
  • Esko
    Esko almost 14 years
    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...
  • Chris K
    Chris K almost 14 years
    @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.
  • abatishchev
    abatishchev almost 14 years
    Nevertheless I think is a good rule to sort members by type (fields, properties, methods) and by name
  • rcollyer
    rcollyer almost 14 years
    +1 for the vicious psychopath.
  • Sandeep Datta
    Sandeep Datta almost 14 years
    "C doesn't exactly have the glut of flow-control" what language? what glut? Please give some examples.
  • Arafangion
    Arafangion almost 14 years
    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.
  • rjh
    rjh almost 14 years
    I love reading these answers because it makes my job seem 100x better.
  • TheLQ
    TheLQ almost 14 years
    Erm... use an decent text editor and change it there? Tabs can be rendered diffrently, and a nice Format tool goes long ways.
  • rjh
    rjh almost 14 years
    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.
  • TheLQ
    TheLQ almost 14 years
    I guess on paper in a meeting room it sounded good, but I pity the programmer who had to follow it
  • TheLQ
    TheLQ almost 14 years
    *clicks minimize button in IDE. Oh, thats what it does
  • detly
    detly almost 14 years
  • TheLQ
    TheLQ almost 14 years
    I sometimes to that actually, but I move them to the bottom. Its helpful in between commits.
  • TheLQ
    TheLQ almost 14 years
    In PHP, it helps with separation. mysql_numRows looks alot better than mysqlNumRows.
  • TheLQ
    TheLQ almost 14 years
    Eww... when I want to read a comment I want something short and easy to read, not an English Paper paragraph.
  • JAB
    JAB almost 14 years
    Were the people who wrote your coding standard not aware of the block comment delimiters that C-style languages have?
  • Frank
    Frank almost 14 years
    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..
  • Frank
    Frank almost 14 years
    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.
  • Frank
    Frank almost 14 years
    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++.
  • Arafangion
    Arafangion almost 14 years
    The general philosophy at that place was that "Pointers and GOTO are evil". Nevermind that pointers aren't optional in C.
  • JUST MY correct OPINION
    JUST MY correct OPINION almost 14 years
    @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.
  • JUST MY correct OPINION
    JUST MY correct OPINION almost 14 years
    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".
  • JUST MY correct OPINION
    JUST MY correct OPINION almost 14 years
    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.)
  • Mark Simpson
    Mark Simpson almost 14 years
    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.
  • Tim Lesher
    Tim Lesher almost 14 years
    @rjh 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.
  • Mitkins
    Mitkins almost 14 years
    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.
  • Viktor Svub
    Viktor Svub almost 14 years
    Feel for you... we're on SVN for 4+ years, but the senior developer hates it and checks in about once per two months, spending the next three days complanining about broken code :/
  • Christian Hayter
    Christian Hayter over 13 years
    And there was me thinking that <tablename>. was a good enough prefix for putting on column names. That's told me.
  • Christian Hayter
    Christian Hayter over 13 years
    What happens to tables not in dbo? :)
  • Warren  P
    Warren P over 13 years
    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?
  • Wayne Werner
    Wayne Werner over 13 years
    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.
  • Donal Fellows
    Donal Fellows over 13 years
    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.
  • Donal Fellows
    Donal Fellows over 13 years
    @Michael: Braces do have semantic meaning in C and many other languages derived from it (they denote the scope of variable contexts).
  • Jon Purdy
    Jon Purdy over 13 years
    I sort methods, members, etc. alphabetically within their respective groups, in both header and source...but only because I'm obsessive.
  • Wayne Werner
    Wayne Werner over 13 years
    Spell check, sure, and reasonable grammar is a good thing. Makes it easier to read. But full sentences not (always) so much.
  • Wayne Werner
    Wayne Werner over 13 years
    So... should programming not be allowed because it can lead to segfaults?
  • corydoras
    corydoras over 13 years
    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?
  • JUST MY correct OPINION
    JUST MY correct OPINION over 13 years
    @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?
  • Saurabh
    Saurabh over 13 years
    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.)
  • Carlos Muñoz
    Carlos Muñoz over 13 years
    You are creating obfuscated code by hand!!!
  • alternative
    alternative over 13 years
    @TheLQ And mysql_num_rows looks a lot better than mysql_numRows and mysql_nrows is the best.
  • Marius Schulz
    Marius Schulz over 13 years
    Of course it's magic – there's a cloud of mysterious smoke and everything just works ...
  • ssss
    ssss over 13 years
    @configurator: You had “tbl” for all fields and “fld” for all tables? :-)))
  • configurator
    configurator over 13 years
    Might as well ban = as it can be used to cause undefined behaviour.
  • John Isaac
    John Isaac over 13 years
    you mean attempted minuscule performance enhancement. "clever optimizations" could actually end up being slower :)
  • Jesse C. Slicer
    Jesse C. Slicer over 13 years
    So why do none of the beginning braces in your example have comments?
  • Stephan Muller
    Stephan Muller over 13 years
    @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.
  • Alexandru
    Alexandru over 13 years
    I think the reason behind this rule is to avoid having arguments and local variables with the same name as members.
  • Frank
    Frank over 13 years
    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.
  • Frank
    Frank over 13 years
    Hmm, right "clearer". +one if list is empty is clearer than if "list is empty" is true.
  • Michael Anderson
    Michael Anderson over 13 years
    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)
  • Esko
    Esko over 13 years
    Just thinking out loud, could "DS" be "Dynamic Strings"? In any case, this stuff is horrible.
  • supercat
    supercat over 13 years
    When posting code on forums, I'll sometimes use things like LT and SHL, to avoid having the operators get munged as HTML.
  • JAB
    JAB about 13 years
    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?
  • Spudley
    Spudley about 13 years
    @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.
  • JAB
    JAB about 13 years
    Ah, so the terminal editors couldn't have their settings changed.
  • Spudley
    Spudley about 13 years
    @JAB - exactly. it was quite a locked down environment.
  • fretje
    fretje almost 13 years
    @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 @joh6nn said).
  • Admin
    Admin over 12 years
    Even "clearer" would be if( (list.isEmpty() == false) == true )...
  • TechZen
    TechZen over 12 years
    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?
  • Art Taylor
    Art Taylor over 12 years
    So you shoved Boehm GC in there and everyone lived happily ever after? And threads are for people who don't understand state machines. :-)
  • Sulthan
    Sulthan over 12 years
    I was taught to use GOTO only for forward jumps. Never use it for backward jumps. Best teaching I've ever had.
  • Asaf
    Asaf about 12 years
    "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.
  • Tim
    Tim about 12 years
    @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.

Related