What was the strangest coding standard rule that you were forced to follow?
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.
Related videos on Youtube
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 > 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, 2020Comments
-
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 over 15 yearsAfter reading thru this list suddenly I feel like I've had a very lucky career to avoid any of this forced standard crap!
-
JasonFruit about 14 yearsAnd 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 over 15 yearsI'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 over 15 yearsBy everyone, your boss means himself.
-
Rik over 15 yearsYeah, magic is hard to maintain, appearantly ;) LOL, though.
-
nickf over 15 yearsyuckers. This is patently the worst bracketing style ever.
-
John Rudy over 15 yearsI'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 over 15 yearsI 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 over 15 yearsAh, 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 over 15 yearsps. The silly 'reason' was so that it would be easier for people to transfer context from C to Java and vice-versa.
-
Kirk Strauser over 15 yearsWell, at that point you might as well give up, right?
-
Kirk Strauser over 15 yearsThat'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 over 15 yearsI 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 over 15 yearsWhat 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 over 15 yearsI'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 over 15 yearsWell... 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 over 15 yearsI 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 over 15 yearsFrom 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 over 15 yearsI really hate that... there's a few people who do that here (it's not a standard or anything though)
-
Bobby Jack over 15 yearsLooks like Whitesmiths style which was used in the original 'Programming Windows' by Petzold - go figure! ;)
-
Bobby Jack over 15 yearsIf anything, the rule should be "always use the ternary operator", an operator of pure beauty :)
-
Bill K over 15 yearsOn 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 over 15 yearsWorkaround: if (!Initialize()) { RetVal=ERR_BADINIT; goto ReturnPoint; } (lots more code) ReturnPoint: return RetVal; } Problem solved! ;)
-
pmlarocque over 15 yearsadding 'ref string sError' to every single function, that best practice they show in computer science 101 at my university!
-
gbjbaanb over 15 yearsfor 'magic' read performance killing unmaintainable obscure nightmare code. He's right.
-
gbjbaanb over 15 yearssee children, look what happens if you don't play nicely with others :-)
-
matt b over 15 yearsGod I hate those types of comments - all they do is add visual litter to the screen
-
vitule over 15 yearsbuttonNameUnderscoreClick()
-
Martin Beckett over 15 yearsPrefixing globals with 'g' is simpler than putting a "here be dragons" comment on every fucntion.
-
paercebal over 15 yearsUp 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 over 15 yearsUsing one exit point should be encouraged, but certainly NOT being enforced. Especially if you consider early-out conditions.
-
Mitkins over 15 yearsOne test per 8 lines is actually not very many at all... Do you mean you can have AT MOST 165 tests?
-
John Rudy over 15 yearsRules 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 over 15 yearsGenerally 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 over 15 yearsMy experience is Oracle people like to do things like this.
-
Craig over 15 yearsSounds like a rule developed pre source control. Or due to programmers only checking in once a week.
-
Robert P over 15 yearsThe 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 over 15 yearsWell->maybe_he_was(tired_of, exceptionally_long_underscore_names, and_so_banned, them_from_use);
-
moffdub over 15 yearsI avoid using reflection for major parts of design, but an outright ban is silly.
-
Jonathan Leffler over 15 yearsLuxury: 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 over 15 yearsWell 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 over 15 yearsI 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 over 15 yearsYes, the two spacers should have given in.
-
JimDaniel over 15 yearsMaybe you mean member variables? BTW, my company does not like this either.
-
Hans over 15 yearsOops, yes that is indeed what I meant. What reasons are you given? I just a "I don't like it" during code-reviews.
-
pookleblinky over 15 years"When I was your age, we only had 2 characters! And it was case-insensitive!"
-
CodingWithSpike over 15 yearsSadly, 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 over 15 yearsWe 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 over 15 yearsI 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 over 15 yearsSimply put multiple returns increase testing complexity. Further it increases the likelihood that you've done something wrong
-
NotMe over 15 yearsI 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 over 15 yearsWith all that and NASA still couldn't figure out whether to calculate in kilometers or miles...
-
Jonathan Leffler over 15 yearsYeah, 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 over 15 yearsThats why tab identation is so great. Everyone can change the size in his editor ;)
-
Kirk Strauser over 15 yearsOK, that's a pretty reasonable case for overriding the rule.
-
Kirk Strauser over 15 yearsI am sorry, so terribly sorry...
-
Kirk Strauser over 15 yearsNo kidding. I bet it took forever to go through and remove all those SQL injections. ;-)
-
moffdub over 15 yearsI failed to mention that our IDE has a menu item titled "Generate Getters and Setters..."
-
Paulius over 15 yearsBuilding unmaintainable code for the future
-
Steve Jessop over 15 yearsHas 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 over 15 years"50 possible identifiers ought to be enough for anyone" :p
-
Chris Vest over 15 yearsmy preference: ... from customer left join address on (address.id = customer.address_id)
-
Chris Vest over 15 yearssounds like someone was missing an algebraic Maybe type.
-
TonJ over 15 yearsThis 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 over 15 yearsOddly, 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 over 15 yearsThat is pure evilness. I am sure your boss/TL is an overlord just waiting for his opportunity.
-
Alan Hensel over 15 yearsYeah, 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 over 15 yearsI hope you didn't use any software from GNU = "GNU is Not Unix".
-
T.E.D. over 15 yearsActually, 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 over 15 yearsI would say, that is pretty strange.
-
andriy over 15 yearsThe 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 over 15 yearsI 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 over 15 yearsThe 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 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 over 15 yearsif 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 over 15 yearsHRESULTS are useless unless you are using COM. It is not a good idea to force that paradigm on better practices. UGH!
-
Tim over 15 yearsmultiple returns (except for an initial error check) are the sign of poor programming and made code very complicated very quickly.
-
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 over 15 yearsActually he is pretty nice in person and a good business man, but one would never know from these coding rules... :)
-
Daniel Rikowski over 15 yearsOf course! Developers are supposed to write code, not waste time writing comments :)
-
Andreas Magnusson over 15 yearsHow 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 over 15 yearsHoly sh... The T_guy who invented this nightmare should be killed with a F_gun and sent to TSX_hell.
-
Tetha over 15 yearsin that case, write yourself a script "Generate Getter- and SetterTests".
-
Tetha over 15 yearsif 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 over 15 yearsI 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 over 15 yearsPookleblinky--there really were systems with those rules. The second computer I ever worked with.
-
causa prima over 15 yearsHe'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 over 15 yearsThey 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 over 15 yearsStep 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 over 15 yearsYou can set the indent in the environment options!
-
causa prima over 15 yearsI'm not too happy with i and never use it. Sometimes x, y and perhaps even z make excellent sense, though.
-
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 over 15 yearsThis 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 over 15 yearsNah: 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 over 15 yearsrofl .. writing fortran in C.
-
CodeIT over 15 yearsDamn, 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 over 15 yearsomg, who the hell would come up with rules like this??? most importantly: how the hell does your team manage to code??
-
user1925801 over 15 yearsi 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 over 15 yearsdon'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 over 15 yearsburying queries in compiled code is such a pain, I'm 100% behind 100% sprocs policy for the abstraction alone
-
Lance Fisher over 15 yearsYour choice: multiple returns or more nested if statements. I'll take multiple returns.
-
yuriks over 15 yearsAnd pretty much all of the C++ standard library.
-
Victor Stanciu about 15 years+1 for working with programmers that are afraid of OO
-
recursive9 about 15 yearsThat'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 about 15 yearsWhat happens if you have 164? 166?
-
Brian Postow about 15 yearsI really like the g, and m prefixes... I and O seem a bit weird...
-
John MacIntyre about 15 yearsThat sucks, but at least there was a reason for it.
-
Kostis about 15 yearsI 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 about 15 yearsMore like 6 lines.
-
MbaiMburu about 15 yearsI 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 about 15 yearsThree cheers for capitalism!
-
joh6nn about 15 yearsthat'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 about 15 yearsg_ 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 about 15 yearsWell, Linus has stated that C++ is a horrible language: thread.gmane.org/gmane.comp.version-control.git/57643/…
-
Dineshkumar about 15 yearsYay for survival of the fittest...this guy didn't deserve to be running his own software business.
-
ShockwaveNN about 15 yearsPorcupine Tree are awesome! :)
-
tuinstoel about 15 yearsWho me? I can tolerate the porcupine trees but to say that I like them... no, not really. Or do you mean someone else?
-
ShockwaveNN about 15 yearsI 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 about 15 years...and that never works. :P
-
Rune Jeppesen almost 15 yearsShouldn'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. almost 15 yearsYou 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 almost 15 yearsWe had tbl and fld for all fields and tables. Completely useless...
-
thomasrutter almost 15 yearshaha 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 almost 15 yearsOf course not! "The database does that." (actual quote from co-worker)
-
Frew Schmidt almost 15 yearsNote: the location of the { matters in Javascript :-(
-
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 almost 15 yearsI 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 almost 15 yearsWasn't there an old shell that was written entirely like this? Basically to the point where it didn't even resemble C.
-
Mr. Shickadance almost 15 yearsThe last sentence was great. How could someone be taken seriously when they make decisions like this?
-
Mr. Shickadance almost 15 yearsThe last one about the psychopath would get some people killed almost immediately.
-
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 almost 15 yearsnames beginning with _ are reserved for the implementation. trailing underscore is a convention popular in the STL.
-
David Thornley almost 15 yearsC'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 over 14 yearsI 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 over 14 yearsYeah! And comments make the build slower!
-
muusbolla over 14 yearsIf 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 over 14 yearsI 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 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 over 14 yearsSteven, this reminds me the monkey experiment story :o) freekvermeulen.blogspot.com/2008/08/…
-
Steven A. Lowe over 14 years@[Nick D]: yes, me too - hence the code-name "CodeMonkey" ;-)
-
7wp over 14 yearsIt baffles me how such people even get hired????
-
Tyler McHenry over 14 yearsHiring 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 over 14 yearsThis 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 over 14 yearsIn 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 over 14 yearsI can understand the begin/end stuff--{} look too much like ()!
-
T.E.D. over 14 yearsI'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 over 14 yearsI recommend to people with indenting problems to statistically determine the original authors tab indention and replace it with tabs. Works surprisingly well.
-
Dave over 14 yearsnot 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 over 14 yearsmaibe 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 over 14 yearsThat's how I came to love AccuRev's option to "Ignore Whitespace" when diffing. Simply awesome.
-
topski over 14 yearsCan'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 over 14 yearsThe 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 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 over 14 yearsI 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 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 over 14 years@Sander: That's belief in the broken windows theory. (Sorry, couldn't resist the irony.)
-
Corey Porter over 14 yearsI 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 over 14 yearsThis 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̲̳̳ over 14 yearsI imagine your dev team must be masters of reverse engineering
-
Brent Bradburn over 14 yearsFair use (I'm poking fun) -- "Framework Design Guidelines", Cwalina and Abrams
-
Brent Bradburn over 14 yearsBy 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 over 14 years3 seems like a fine decision to me but maybe I'm just one of those wimpy Europeans who likes compromises too much.
-
David Thornley over 14 yearsHeck, the BASIC interpreters we worked with a long time ago had two-character variable names. Why complain about 5?
-
andriy over 14 yearsUgh. 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 over 14 yearsTo "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 about 14 yearsDown with those wizards!! Always around, with their magic, stealing our jobs, seducing our women and corrupting our childrens!
-
ErikE about 14 yearsI just barfed in my mouth a little.
-
BlueRaja - Danny Pflughoeft about 14 yearsFor 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 about 14 yearsmaybe (((a)[(i)]).x) += (((((b)[(i)]).y) + (d)) - (7)); ?
-
Saurabh about 14 yearsActually 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 about 14 yearsWhen 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 about 14 yearsOMG! Don't most IDE text editors do curly-brace highlighting/matching now?
-
JBRWilkinson about 14 yearsWhat's with the phrase 'here be dragons'? I've seen that at multiple companies - where is it from?
-
ShockwaveNN about 14 years@JBRWilkinson en.wikipedia.org/wiki/Here_be_dragons
-
JBRWilkinson about 14 yearsThe OP is talking about putting the table name after 'ID', which is just weird.
-
ZJR about 14 years+1 'cause now I fancy a drink too!
-
Vinz about 14 yearsDoes this imply it's forbidden to throw exceptions too? Throwing an exception can also be seen as a return point...
-
CMircea almost 14 yearsI 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 almost 14 yearsUsing 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 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 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 almost 14 yearsBanning pointers is bad. Banning GOTO makes perfect sense. Shame on you for wanting to use goto.
-
Thomas Eding almost 14 yearsHow do numbered local variable names solve the problem? You still have the same number of identifiers... only relabelled. I don't get it.
-
Arafangion almost 14 yearsIt'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 almost 14 years@trinithis: It's the number of unique identifiers which is limited.
-
Esko almost 14 yearsLabeled 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 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 almost 14 yearsNevertheless I think is a good rule to sort members by type (fields, properties, methods) and by name
-
rcollyer almost 14 years+1 for the vicious psychopath.
-
Sandeep Datta almost 14 years"C doesn't exactly have the glut of flow-control" what language? what glut? Please give some examples.
-
Arafangion almost 14 yearsSDX2000: 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 almost 14 yearsI love reading these answers because it makes my job seem 100x better.
-
TheLQ almost 14 yearsErm... use an decent text editor and change it there? Tabs can be rendered diffrently, and a nice Format tool goes long ways.
-
rjh almost 14 yearsFor 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 almost 14 yearsI guess on paper in a meeting room it sounded good, but I pity the programmer who had to follow it
-
TheLQ almost 14 years*clicks minimize button in IDE. Oh, thats what it does
-
detly almost 14 yearsOr Grandma's Cooking Secret...
-
TheLQ almost 14 yearsI sometimes to that actually, but I move them to the bottom. Its helpful in between commits.
-
TheLQ almost 14 yearsIn PHP, it helps with separation. mysql_numRows looks alot better than mysqlNumRows.
-
TheLQ almost 14 yearsEww... when I want to read a comment I want something short and easy to read, not an English Paper paragraph.
-
JAB almost 14 yearsWere the people who wrote your coding standard not aware of the block comment delimiters that C-style languages have?
-
Frank almost 14 yearsWell, 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 almost 14 yearsWell, 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 almost 14 yearsI 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 almost 14 yearsThe general philosophy at that place was that "Pointers and GOTO are evil". Nevermind that pointers aren't optional in C.
-
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 almost 14 yearsI'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 almost 14 yearsAnybody 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 almost 14 yearsIt 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 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 almost 14 yearsIt 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 almost 14 yearsFeel 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 over 13 yearsAnd there was me thinking that
<tablename>.
was a good enough prefix for putting on column names. That's told me. -
Christian Hayter over 13 yearsWhat happens to tables not in
dbo
? :) -
Warren P over 13 yearsunderscores 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 over 13 yearsGOTO is just as evil as JMP in assembly. Sure you can use it badly (heck, using
break
andcontinue
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 over 13 yearsI 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 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 over 13 yearsI sort methods, members, etc. alphabetically within their respective groups, in both header and source...but only because I'm obsessive.
-
Wayne Werner over 13 yearsSpell check, sure, and reasonable grammar is a good thing. Makes it easier to read. But full sentences not (always) so much.
-
Wayne Werner over 13 yearsSo... should programming not be allowed because it can lead to segfaults?
-
corydoras over 13 yearsThere 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 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 over 13 yearsThere 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
andlongjmp
.) -
Carlos Muñoz over 13 yearsYou are creating obfuscated code by hand!!!
-
alternative over 13 years@TheLQ And mysql_num_rows looks a lot better than mysql_numRows and mysql_nrows is the best.
-
Marius Schulz over 13 yearsOf course it's magic – there's a cloud of mysterious smoke and everything just works ...
-
ssss over 13 years@configurator: You had “tbl” for all fields and “fld” for all tables? :-)))
-
configurator over 13 yearsMight as well ban
=
as it can be used to cause undefined behaviour. -
John Isaac over 13 yearsyou mean attempted minuscule performance enhancement. "clever optimizations" could actually end up being slower :)
-
Jesse C. Slicer over 13 yearsSo why do none of the beginning braces in your example have comments?
-
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 over 13 yearsI think the reason behind this rule is to avoid having arguments and local variables with the same name as members.
-
Frank over 13 yearsOn 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 over 13 yearsHmm, right "clearer". +one
if list is empty
is clearer thanif "list is empty" is true
. -
Michael Anderson over 13 yearsGet 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 over 13 yearsJust thinking out loud, could "DS" be "Dynamic Strings"? In any case, this stuff is horrible.
-
supercat over 13 yearsWhen posting code on forums, I'll sometimes use things like LT and SHL, to avoid having the operators get munged as HTML.
-
JAB about 13 yearsIf 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 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 about 13 yearsAh, so the terminal editors couldn't have their settings changed.
-
Spudley about 13 years@JAB - exactly. it was quite a locked down environment.
-
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 over 12 yearsEven "clearer" would be
if( (list.isEmpty() == false) == true )...
-
TechZen over 12 yearsPeople 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 over 12 yearsSo you shoved Boehm GC in there and everyone lived happily ever after? And threads are for people who don't understand state machines. :-)
-
Sulthan over 12 yearsI was taught to use GOTO only for forward jumps. Never use it for backward jumps. Best teaching I've ever had.
-
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 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.