-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanswers.json
More file actions
52 lines (52 loc) · 54.1 KB
/
answers.json
File metadata and controls
52 lines (52 loc) · 54.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
[
{"ID": 1, "ANSWERS": ["I ", " it when the use of multiple returns is banned."], "COMMENTS": ["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.", "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.", "Workaround: if (!Initialize()) { RetVal=ERR_BADINIT; goto ReturnPoint; } (lots more code) ReturnPoint: return RetVal; } Problem solved! ;)", "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 ...", "Your choice: multiple returns or more nested if statements. I'll take multiple returns."], "VOTES": "434"},
{"ID": 2, "ANSWERS": ["reverse indentation. For example:", "and:"], "COMMENTS": ["Oh my god ... Can I meet the sociopath who came up with that one? He could teach me a thing or two about misanthropy.", "That can't possibly be true.", "Every time you reverse the indentation, God kills a maintenance developer.", "OMG, are you kidding?", "saves precious bytes... priceless, use it a lot"], "VOTES": "333"},
{"ID": 3, "ANSWERS": ["Maybe not the most outlandish one you'll get, but "], "COMMENTS": ["Isn't this just hungarian notation for DB's?", "Isn't that like prefixing variables with var?", "In a similar vein, I hate when ID columns in databases are prefixed with the table name, like in the product table there'd be a productid column. Redundancy that sometimes makes scripting without an ORM more of a headache than it needs to be", "I actually prefer the ID column to be prefixed with the table name. Makes writing queries a bit easier. And for foreign keys you can have the foreign key field the same as the key field.", "On a similar note, I hate it when table names must be singular. My instinct is to name a table that holds, say, customers, \"Customers\", not \"Customer\". Sounds minor, till you realize all the trouble you would save if only you could name your table \"Transactions\" instead of \"[Transaction]\"."], "VOTES": "326"},
{"ID": 4, "ANSWERS": ["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:", "But most people use it to determine the type.", "This is confusing, because although both numbers are integers, everybody knows, you can't compare apples with pears."], "COMMENTS": ["See this Joel on Software post about how ", " use of Hungarian notation can help reduce bugs: ", "Of course by using C++ instead of C you can write code so that the compiler gives you an error when comparing apples to pears.", "Yes, Joel got it right. I wish compilers could be made to enforce Joel's version of it.", "Shouldn't that be \"int cntApples = 0; int cntPeas = 0;\"? Ie. The prefix is the variable \"kind\".", "At least the first one is correct ... everything with \"Apple\" in it needs to be prefixed with \"i\". ;)"], "VOTES": "248"},
{"ID": 5, "ANSWERS": ["No ternary operator allowed where I currently work:", "... 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."], "COMMENTS": ["By everyone, your boss means himself.", "I used to fall into this camp ... But grew out of it, and have learned to love the conditional operator (when it's appropriate).", "If anything, the rule should be \"always use the ternary operator\", an operator of pure beauty :)", "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...", "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."], "VOTES": "240"},
{"ID": 6, "ANSWERS": ["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."], "COMMENTS": ["I really hate that... there's a few people who do that here (it's not a standard or anything though)", "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 ... )", "Sounds like a rule developed pre source control. Or due to programmers only checking in once a week.", "I love reading these answers because it makes my job seem 100x better.", "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 :/"], "VOTES": "239"},
{"ID": 7, "ANSWERS": ["I once worked under the tyranny of the ", ".", "The ", " was the pure master of MS Excel and VBA, as well as databases (", ").", "Of course, his ", " skills gave him an ", " vision of development problems and project management solutions: While not exactly coding standards in the strictest sense, the ", " regularly had new ideas about \"coding standards\" and \"best practices\" he tried (and oftentimes succeeded) to impose on us. For example:", "All but the ", ", ", " and ", " were implemented despite our protests. Of course, over the time, some were discovered, ", ", broken, and abandoned altogether.", "Of course, the ", " credibility never suffered for that: Among the higher management, he remained a \"top gun\" technical expert...", "This produced some amusing side effects, as you can see by following the link "], "COMMENTS": ["Re: 1-indexing. Sometimes you just have to stand up and say something strong like \"that's stupid and wrong\". Draw a line in the sand. Forget placating egos and just say it. I can almost guarantee that every other worthwhile programmer will immediately start nodding and joining in.", "@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... ^_^ ...", "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.", "@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.", "@paercebal: En g\u00e9n\u00e9rale, c'est correctement \u00e9crit, sauf que quelques petits erreurs: \u00absquatch\u00bb: \u00e7a doit \u00eatre \u00absquash\u00bb; \u00abthis one day\u00bb: en ce context-l\u00e0, on dirait \u00abthat day\u00bb; \u00abstocked procedures\u00bb: \u00abstock procedures\u00bb; \u00abchocked\u00bb s'\u00e9crit \u00abchoked\u00bb. Aussi, dans les commentaires, vous utilisez \u00b0mentionned\u00bb, ce qui doit \u00eatre \u00abmentioned\u00bb Mais vraiment, tout \u00e7a ne justifie pas une telle plainte. Au contraire, vous y montrez une excellente ma\u00eetrise de l'anglais; f\u00e9licitations!", "\r\n ", "\r\n "], "VOTES": "204"},
{"ID": 8, "ANSWERS": ["Back in the 80's/90's, I worked for an aircraft simulator company that used FORTRAN. Our FORTRAN compiler had a limit of 8 characters for variable names. The company's coding standards reserved the first three of them for Hungarian-notation style info. So we had to try and create meaningful variable names with just 5 characters!"], "COMMENTS": ["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, ...", "\"When I was your age, we only had 2 characters! And it was case-insensitive!\"", "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.", "\"50 possible identifiers ought to be enough for anyone\" :p", "Heck, the BASIC interpreters we worked with a long time ago had two-character variable names. Why complain about 5?"], "VOTES": "131"},
{"ID": 9, "ANSWERS": ["I worked at a place that had a merger between 2 companies. The 'dominant' one had a major server written in K&R C (i.e. pre-ANSI). They forced the Java teams (from both offices -- probably 20 devs total) to use this format, which gleefully ignored the 2 pillars of the \"brace debate\" and goes straight to crazy:"], "COMMENTS": ["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.\")", "Looks like Whitesmiths style which was used in the original 'Programming Windows' by Petzold - go figure! ;)", "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.", "@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.", "This is actually my preferred style, but everything in the world (Visual Studio especially) defaults to other modes, so I've given up. ", " do I like it? The braces ", " \"part of\" the contained code -- they force it to \"look like\" a single statement to the if, which is what it expects."], "VOTES": "107"},
{"ID": 10, "ANSWERS": ["Forbidden:", "Allowed:"], "COMMENTS": ["Others have argued that ", " is a C Idiom for the first.", "If I understand modern, new-fangled smileys correctly, this standard is making the poor, overworked for statement cry!", "This is a de facto rule here. VC6 issues a compiler warning about while(true), but not about for(;;). Otherwise they're equivalent. So we pick the warning-free one.", "Bjarne S. said in his book, \"for (;;) should be read as forever\". If it's good enough for the creator of C++, it should be good enough for you. :-)", "In the very first C program I worked on, someone had added #define ever (;;) so you could say \"for ever {...}\""], "VOTES": "104"},
{"ID": 11, "ANSWERS": ["a friend of mine - we'll call him CodeMonkey - got his first job out of college [", " years ago] doing in-house development in COBOL. His first program was rejected as 'not complying with our standards' because it used... [shudder!] nested IF statements", "now, CodeMonkey was not shy and was certain of his abilities, so he persisted in asking everyone up the chain and down the aisle why this rule existed. Most claimed they did not know, some made up stuff about 'readability', and finally one person remembered the original reason: the first version of the COBOL compiler they used had a bug and didn't handle nested IF statements correctly.", "This compiler bug, of course, had been fixed for at least a decade, but ", ". [baaa!]", "CodeMonkey was successful in getting the standards changed - eventually!"], "COMMENTS": ["Steven, this reminds me the monkey experiment story :o) ", "@[Nick D]: yes, me too - hence the code-name \"CodeMonkey\" ;-)", "Or ", "...", "The reason might have been wrong, but it is still good to avoid nested ifs - "], "VOTES": "101"},
{"ID": 12, "ANSWERS": ["Once worked on a project where underscores were banned. And I mean totally banned. So in a c# winforms app, whenever we added a new event handler (e.g. for a button) we'd have to rename the default method name from buttonName_Click() to something else, just to satisfy the ego of the guy that wrote the coding standards. To this day I don't know what he had against the humble underscore"], "COMMENTS": ["Maybe _ was broken on his keyboard ;)", "buttonNameUnderscoreClick()", "Has the unfortunate side-effect of preventing the use of ", " and ", " for debugging. And #if __cplusplus extern \"C\" in header files. And the integral types in stdint.h. And size_t.", "Good thing this was C# then", "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."], "VOTES": "97"},
{"ID": 13, "ANSWERS": ["Totally useless database naming conventions.\nEvery table name has to start with a number. The numbers show which kind of data is in the table.", "This makes it hard to find a table if you only know the first letter of its name.\nAlso - as this is a mssql database - we have to surround tablenames with square brackets everywhere."], "COMMENTS": ["I am sorry, so terribly sorry...", "Wow - good one. I guess using Letters was out of the question? Not that THAT is a good idea either but at least you don't have to quote all table names.", "mind boggling...who came up with that? the dba?"], "VOTES": "92"},
{"ID": 14, "ANSWERS": ["We were doing a C++ project and the team lead was a Pascal guy.", "So we had a coding standard include file to redefine all that pesky C and C++ syntax:", "but wait there's more!", "etc. It's hard to remember after all this time.", "This took what would have been perfectly readable C++ code and made it illegible to anyone except the team lead.", "We also had to use reverse Hungarian notation, i.e.", "although oddly I grew to like this. "], "COMMENTS": ["Building unmaintainable code for the future", "Hungarian notation done right is okay. Done wrong... ick. A proper type system beats both.", "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.", "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.", "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)."], "VOTES": "90"},
{"ID": 15, "ANSWERS": ["At a former job:", "Yes, that's right. All of the fields, in every single table. So that we can tell it's a field."], "COMMENTS": ["and you had no special prefix for primary key fields???", "@Czimi: I forgot to mention that. Every table has a field called FI_ID used as the primary key.", "Holy sh... The T_guy who invented this nightmare should be killed with a F_gun and sent to TSX_hell.", "We had tbl and fld for all fields and tables. Completely useless...", "@configurator: You had \u201ctbl\u201d for all fields and \u201cfld\u201d for all tables? :-)))"], "VOTES": "88"},
{"ID": 16, "ANSWERS": ["A buddy of mine encountered this rule while working at a government job. The use of ++ (pre or post) was completely banned. The reason: Different compilers might interpret it differently. "], "COMMENTS": ["Well, at that point you might as well give up, right?", "Some one got bitten by not understanding the difference between postfix and prefix, claimed compiler bug, then inflicted it on other people, me thinks.", "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.", "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!", "Might as well ban ", " as it can be used to cause undefined behaviour."], "VOTES": "84"},
{"ID": 17, "ANSWERS": ["Half of the team favored four-space indentation; the other half favored two-space indentation.", "As you can guess, the coding standard mandated three, so as to \"offend all equally\" (a direct quote)."], "COMMENTS": ["Thats why tab identation is so great. Everyone can change the size in his editor ;)", "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.", "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.", "...and that never works. :P", "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."], "VOTES": "81"},
{"ID": 18, "ANSWERS": ["Not being able to use Reflection as the manager claimed it involved too much 'magic'."], "COMMENTS": ["Yeah, magic is hard to maintain, appearantly ;) LOL, though.", "That's probably the right rule, for the wrong reasons :)", "for 'magic' read performance killing unmaintainable obscure nightmare code. He's right.", "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.", "Down with those ", "!! Always around, with their ", ", stealing our jobs, seducing our women and corrupting our childrens!"], "VOTES": "74"},
{"ID": 19, "ANSWERS": ["The very strangest one I had, and one which took me quite some time to overthrow, was when the owner of our company demanded that our new product be IE only. If it could work on FireFox, that was OK, but it had to be IE only.", "This might not sound too strange, except for one little flaw. All of the software was for a bespoke server software package, running on Linux, and all client boxes that our customer was buying were Linux. Short of trying to figure out how to get Wine (in those days, very unreliable) up and running on all of these boxes and seeing if we could get IE running and training their admins how to debug Wine problems, it simply wasn't possible to meet the owner's request. The problem was that he was doing the Web design and simply didn't know how to make Web sites compliant with FireFox.", "It probably won't shock you to know that that our company went bankrupt."], "COMMENTS": ["I would say, that is pretty strange.", "Three cheers for capitalism!", "Yay for survival of the fittest...this guy didn't deserve to be running his own software business.", "The last sentence was great. How could someone be taken seriously when they make decisions like this?"], "VOTES": "71"},
{"ID": 20, "ANSWERS": ["At my current work we have two rules which are really mean:", " Every time we create a new field in a database table we have to add additional reserve fields for future use. These reserve fields are numbered (because no one knows which data they will hold some day) The next time we need a new field we first look for an unused reserve field.", "So we end up with with ", " containing the e-mail address of the customer.", "At one day our boss thought about introducing ", ", but fortunatly we could convince him not to do it.", " One of our products is written in VB6 and VB6 has a limit of the total count of different identifier names and since the code is very large, we constantly run into this limit. As a \"solution\" all local variable names are numbered:", "Although that effectively circumvents the identifier limit, these two rules combined lead to beautiful code like this:", "You can imagine how hard it is to fix old or someone else's code...", " Now we are also using \"reserve procedures\" for private members:", " It seems that this code pattern is becoming more and more popular. See this ", " post to learn more: ", " :)"], "COMMENTS": ["No kidding. I bet it took forever to go through and remove all those SQL injections. ;-)", "That is pure evilness. I am sure your boss/TL is an overlord just waiting for his opportunity.", "omg, who the hell would come up with rules like this??? most importantly: how the hell does your team manage to code??", "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.", "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' ;)"], "VOTES": "54"},
{"ID": 21, "ANSWERS": ["Back in my C++ days we were not allowed to use ==,>=, <=,&&, etc. there were macros for this ...", "this was obviously to deal with the \"old accidental assignment in conditional bug\", however we ", " had the rule \"put constants before variables\", so", "Just remembered, the simplest coding standard I ever heard was \"Write code as if the next maintainer is a vicious psychopath who knows where you live.\""], "COMMENTS": ["rofl .. writing fortran in C.", "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.", "The last one about the psychopath would get some people killed almost immediately.", "+1 for the vicious psychopath.", "When posting code on forums, I'll sometimes use things like LT and SHL, to avoid having the operators get munged as HTML."], "VOTES": "53"},
{"ID": 22, "ANSWERS": ["Hungarian notation in general."], "COMMENTS": ["Well, I like H/N for control on a page. It's much easier to find all the textbox controls in an IntelliSense dropdown when all I have to look for is txtFooBar.", "HUngarian notation is not evil, just need to be used properly ", "I will concede with respect to controls. Then Hungarian notation can be helpful. In general though, I think Hungarian notation is obsolete, and generally misused. It has drifted from it's original intention.", "Horribly misused, yes. Wrong, no.", "A lot of people start an interface name with an I, IEnumerable, IList... In .Net framework al the interfaces start with an I."], "VOTES": "45"},
{"ID": 23, "ANSWERS": ["I've had a lot of ", " rules, but not a lot that I considered downright strange.", "The sillyiest was on a NASA job I worked back in the early 90's. This was a huge job, with well over 100 developers on it. The experienced developers who wrote the coding standards decided that every source file should begin with a four letter acronym, and the first letter had to stand for the group that was responsible for the file. This was probably a great idea for the old FORTRAN 77 projects they were used to. ", "However, this was an ", " project, with a nice hierarchal library structure, so it made no sense at all. Every directory was full of files starting with the same letter, followed by 3 more nonsense leters, an underscore, and then part of the file name that mattered. All the Ada packages had to start with this same five-character wart. Ada \"use\" clauses were not allowed either (arguably a good thing under normal circumstances), so that meant any reference to any identifier that wasn't local to that source file ", " had to include this useless wart. There probably should have been an insurrection over this, but the entire project was staffed by junior programmers and fresh from college new hires (myself being the latter).", "A typical assignment statement (already verbose in Ada) would end up looking something like this:", "Fortunately they were at least enlightened enough to allow us more than 80 columns! Still, the facility wart was hated enough that it became boilerplate code at the top of everyone's source files to use Ada \"renames\" to get rid of the wart. There'd be one rename for each imported (\"withed\") package. Like this:", "What the more creative among us took to doing was trying to ", " the wart to make an acutally sensible (or silly) package name. (I know what you are thinking, but explitives were not allowed and shame on you! That's disgusting). For example, I was in the ", "ommon code group, and I needed to make a package to interface with the ", "orkstation group. After a brainstorming session with the Workstation guy, we decided to name our packages so that someone needing both would have to write:"], "COMMENTS": ["With all that and NASA still couldn't figure out whether to calculate in kilometers or miles...", "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!"], "VOTES": "43"},
{"ID": 24, "ANSWERS": ["When I started working at one place, and started entering my code into the source control, my boss suddenly came up to me, and asked me to stop committing so much. He told me it is discouraged to do more than 1 commit per-day for a developer because it litters the source control. I simply gaped at him...", "Later I understood that the reason he even came up to me about it is because the SVN server would send him (and 10 more high executives) a mail for each commit someone makes. And by littering the source control I guessed he ment his mailbox."], "COMMENTS": ["Highlight email, click delete, done", "I am definitely ", " a fan of so-called \"chunky check-ins\". Commit when your change is complete, simple as that. I also like to commit at the end of the work day as it enforces in my mind that my code should be compilable and be at least runnable with the rest of the project for other coders the next morning.", "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)", "I agree with all of the above. It's a rooted problem of approaching version control. It has no technological solution. I considered moving to git-svn, which would enable me to work with a local repository and then push things to the SVN repository, but that would have just sent the mails for all of my day's commits in one huge batch, and would have solved nothing for my bosses."], "VOTES": "41"},
{"ID": 25, "ANSWERS": ["Doing all database queries via stored procedures in Sql Server 2000. From complex multi-table queries to simple ones like:", "The arguments in favor of procedures were:", "I know that the procedure topic is quite controversial, so feel free to score my answer negatively ;)"], "COMMENTS": ["Maintainability could be improved if the table and column names are not unique, but the SP names are. This could make code references easier to find. If there are any other, better maintainability advantages, I am not aware of them. Security is the main reason to use SPs.", "I agree that for general purposes it's not 100% wtf, but see this link: ", "\"Security is the main reason to use SPs\" No. Nothing about SP's in SQL Server are more secure. They are only secure when called as a paremeterized queries, which can be done just as well with dynamic SQL.", "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.", "burying queries in compiled code is such a pain, I'm 100% behind 100% sprocs policy for the abstraction alone"], "VOTES": "34"},
{"ID": 26, "ANSWERS": ["There must be 165 unit tests (not necessarily automated) per 1000 lines of code. That works out at one test for roughly every 8 lines. ", "Needless to say, some of the lines of code are quite long, and functions return ", " pointers to allow chaining."], "COMMENTS": ["How is a unit test not automated.", "How did they come up with the magic number 8?", "What happens if you have 164? 166?", "More like 6 lines.", "It depends on how finely grained your tests are too I guess. I'd consider ", " to be a single test, whereas others would bundle 10 of those together and call it a single test."], "VOTES": "33"},
{"ID": 27, "ANSWERS": ["We had to sort all the functions in classes alphabetically, to make them \"easier to find\".\nNever mind the ide had a drop down. That was too many clicks.", "(same tech lead wrote an app to remove all comments from our source code)."], "COMMENTS": ["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.)", "Of course! Developers are supposed to write code, not waste time writing comments :)", "Yeah! And comments make the build slower!", "Nevertheless I think is a good rule to sort members by type (fields, properties, methods) and by name", "I sort methods, members, etc. alphabetically within their respective groups, in both header and source...but only because I'm obsessive."], "VOTES": "30"},
{"ID": 28, "ANSWERS": ["In 1987 or so, I took a job with a company that hired me because I was one of a small handful of people who knew how to use Revelation. Revelation, if you've never heard of it, was essentially a PC-based implementation of the Pick operating system - which, if you've never heard of it, got its name from its inventor, the fabulously-named Dick Pick. Much can be said about the Pick OS, most of it good. A number of supermini vendors (Prime and MIPS, at least) used Pick, or their own custom implementations of it.", "This company was a Prime shop, and for their in-house systems they used Information. (No, that was really its name: it was Prime's implementation of Pick.) They had a contract with the state to build a PC-based system, and had put about a year into their Revelation project before the guy doing all the work, who was also their MIS director, decided he couldn't do both jobs anymore and hired me.", "At any rate, he'd established a number of coding standards for their Prime-based software, many of which derived from two basic conditions: 1) the use of 80-column dumb terminals, and 2) the fact that since Prime didn't have a visual editor, he'd written his own. Because of the magic portability of Pick code, he'd brought his editor down into Revelation, and had built the entire project on the PC using it.", "Revelation, of course, being PC-based, had a perfectly good full-screen editor, and didn't object when you went past column 80. However, for the first several months I was there, he insisted that I use his editor and his standards.", "So, the first standard was that every line of code had to be commented. Every line. No exceptions. His rationale for that was that even if your comment said exactly what you had just written in the code, having to comment it meant you at least thought about the line twice. Also, as he cheerfully pointed out, he'd added a command to the editor that formatted each line of code so that you could put an end-of-line comment.", "Oh, yes. When you commented every line of code, it was with ", " comments. In short, the first 64 characters of each line were for code, then there was a semicolon, and then you had 15 characters to describe what your 64 characters did. In short, we were using an assembly language convention to format our Pick/Basic code. This led to things that looked like this:", "(Actually, after 20 years I have finally forgotten R/Basic's line-continuation syntax, so it may have looked different. But you get the idea.)", "Additionally, whenever you had to insert multiline comments, the rule was that you use a flower box:", "Yes, those closing asterisks on each line were required. After all, if you used his editor, it was just a simple editor command to insert a flower box.", "Getting him to relent and let me use Revelation's built-in editor was quite a battle. At first he was insistent, simply because those were the rules. When I objected that a) I already knew the Revelation editor b) it was substantially more functional than his editor, c) other Revelation developers would have the same perspective, he retorted that if I didn't train on his editor I wouldn't ever be able to work on the Prime codebase, which, as we both knew, was not going to happen as long as hell remained unfrozen over. Finally he gave in.", "But the coding standards were the last to go. The flower-box comments in particular were a stupid waste of time, and he fought me tooth and nail on them, saying that if I'd just use the right editor maintaining them would be perfectly easy. (The whole thing got pretty passive-aggressive.) Finally I quietly gave in, and from then on all of the code I brought to code reviews had his precious flower-box comments.", "One day, several months into the job, when I'd pretty much proven myself more than competent (especially in comparison with the remarkable parade of other coders that passed through that office while I worked there), he was looking over my shoulder as I worked, and he noticed I wasn't using flower-box comments. Oh, I said, I wrote a source-code formatter that converts my comments into your style when I print them out. It's easier than maintaining them in the editor. He opened his mouth, thought for a moment, closed it, went away, and we never talked about coding standards again. Both of our jobs got easier after that."], "COMMENTS": ["+1 for the comment formatter when printing", "The flower box should NEVER be overused. I hate it when I'm reading along code, okay nice comment, then see a flower box screaming \"THIS DOES THIS AND THIS AND THIS\""], "VOTES": "29"},
{"ID": 29, "ANSWERS": ["At my first job, all C programs, no matter how simple or complex, had only four functions. You had the main, which called the other three functions in turn. I can't remember their names, but they were something along the lines of begin(), middle(), and end(). begin() opened files and database connections, end() closed them, and middle() did ", ". Needless to say, middle() was a ", " long function. ", "And just to make things even better, all variables had to be global.", "One of my proudest memories of that job is having been part of the general revolt that led to the destruction of those standards."], "COMMENTS": ["I guess on paper in a meeting room it sounded good, but I pity the programmer who had to follow it", "Must've been designed by an English teacher.", "Must have been designed by a COBOL programmer.", "Must have used a lot of ", "'s."], "VOTES": "26"},
{"ID": 30, "ANSWERS": ["My weirdest one was at a contract a couple years ago. @ZombieSheep's weird one was part of it, but not the weirdest one in that company.", "No, the weirdest one in that company was the database naming scheme. Every table was named in all caps, with underscores between the words. Every table had a prefix (generally 1 - 6 characters) which was usually an acronym or an abbreviation of the main table name. Every field of the table was prefixed with the same prefix as well. So, let's say you have a simple schema where people can own cats or dogs. It'd look like this:", "That said, as weird as this felt initially ... It grew on me. The reasons behind it made sense (after you wrapped your brain around it), as the prefixes were there to be reminders of \"recommended\" (and enforced!) table aliases when building joins. The prefixing made the majority of join queries easier to write, as it was very rare that you'd have to explicitly reference a table before the field. ", "Heck, after a while, all of us on the team (6 people on our project) were able to begin referring to tables in conversation by nothing more than the prefix. An acquired taste, to be sure ... But one that grew on me. So much so that I still use it, when I have that freedom. "], "COMMENTS": ["Interesting... It'd take a while to get used to, but I think I'd actually like that one too.", "My experience is Oracle people like to do things like this.", "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. :)", "I just barfed in my mouth a little.", "And there was me thinking that ", " was a good enough prefix for putting on column names. That's told me."], "VOTES": "25"},
{"ID": 31, "ANSWERS": ["Prefix tables with dbo_", "Yes, as in dbo.dbo_tablename."], "COMMENTS": ["LOL, I have a project right now that is sending to another company and that is the way they want the column names in the Excel files we are to send them. I knew that the names had to be the column names in their database (as they wouldn't let us replace them with names that actually made sense in context of the report.)", "Because looking at dbo.tablename is such an eyesore...", "What happens to tables not in ", "? :)"], "VOTES": "25"},
{"ID": 32, "ANSWERS": ["Several WTF's in one VB6 shop (I'm not proud, I was hungry and needed to eat) back in 2002 - 2004.", "The most annoying IMHO, was setting all object references to nothing at the end of the sub/function. This was to \"help\" the compiler reference count. It didn't matter how many tests I performed for the TA to prove it wasn't necessary, Oh no, it still had to be done, ", ". Eventually I gave up and about a year later found an article explaining why it was pants. I bring this to the TA thinking \"Got the fecker!\". He goes \"Yeah, I've known about that for years, but if you start changing the standard the sheep \" meaning other developers, the people he worked with everyday \"will screw it up\". Gob sh1te.", "Others in the same shop.", "Mostly I was writing c++ there (only c++ developer, so made own standards, and enforced with rigor!) with occasional vb, otherwise I wouldn't have lasted."], "COMMENTS": ["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 :)", "TA = Technical Architect, or Technical Guru, a role often appointed, rarely earned. The guy at my current job is EXCELLENT, he raises the bar for everyone.", "\"Never delete code.\" I just imagine my starting days, when there was no syntax coloring by default. Then this would count as torture.", "\r\n ", "\r\n "], "VOTES": "22"},
{"ID": 33, "ANSWERS": ["Every beginning and ending brace was ", " to have a comment:", "That's what led me to write my first Visual Studio plugin to automate that."], "COMMENTS": ["God I hate those types of comments - all they do is add visual litter to the screen", "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!", "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)", "the rule you need in that case should be \"no crazy nested ifs\"", "OMG! Don't most IDE text editors do curly-brace highlighting/matching now?"], "VOTES": "20"},
{"ID": 34, "ANSWERS": ["Wow -- this brings back so many memories of one particular place that I worked: Arizona Department of Transportation. ", "There was a project manager there that didn't understand object-based programming (and didn't want to understand it). ", " ", "(Seriously -- she actually spent a lot of her day reviewing code that we had checked-in to Visual SourceSafe just to make sure we weren't breaking the rules). ", "Considering Visual Basic 4 had just released (this was about 12 years ago), and considering that the Windows forms application we were building in VB4 ", ", this made development ... complicated. ", "A buddy of mine actually tried to get around this problem by encapsulating his 'object code' inside dummy 'forms' and she eventually caught on that he was just (* ", " *) hiding his objects!", "Needless to say, I only lasted about 3 months there. ", "Gosh, I disliked that woman's thinking."], "COMMENTS": ["It baffles me how such people even get hired????", "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.", "@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.", "Actually -- she was a contractor. Didn't have much senority in terms of years.", "I'm amazed. I bet she ended up with a pretty good grasp of OOP anyway in order to detect all the obfuscations used to get round her."], "VOTES": "14"},
{"ID": 35, "ANSWERS": ["What drives me nuts is people suffixing the ID field of a table with the name of the table. What the hell is wrong with just ID? You're going to have to alias it anyway... for the love of all that is sacred!", "Imagine what your SQL statements look like when you've got id fields called IDSEWEBLASTCUSTOMERACTION and IDSEEVENTLOGGER."], "COMMENTS": ["Actually I think it makes queries easier to write and read. I do this. SELECT * FROM Person P LEFT JOIN PhoneNumber PN ON P.PersonID = PN.PersonID", "Gotta agree...the suffixing makes database design easier...specially on tables with a lot of foreign keys.", "my preference: ... from customer left join address on (address.id = customer.address_id)", "Why do you have alias it anyway? Don't understand.", "The OP is talking about putting the table name ", " 'ID', which is just weird."], "VOTES": "13"},
{"ID": 36, "ANSWERS": ["You must use only five letter table names and the last two character is reserved for ", ". "], "COMMENTS": [], "VOTES": "12"},
{"ID": 37, "ANSWERS": ["The strangest one i saw was database table naming where the tables were prefaced with a TLA for functional area, eg accounting ACC then a 3 digit number to (overide the default sort) and then the table name.", "Plus this was extended into the column names as well.", "ACC100_AccountCode", "it was a nightmare to read a query, they were so unreadable."], "COMMENTS": ["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\""], "VOTES": "11"},
{"ID": 38, "ANSWERS": ["Applying s_ to variables and methods which were deemed \"safety critical\" for software that was part of a control system. Couple this with the other rule about putting m_ on the front of member variables and you'd get something ridiculous like \"s_m_blah()\", which is darn annoying to write and not very readable in my opinion. In the end some 'safety expert' was supposed to gain insight by looking at the code and determining something from it by using those \"s_\" - in practice, they didn't know c++ too well so they couldn't do much other than make reports on the number of identifiers that we'd marked as 'safety critical'. Utter nonsense... "], "COMMENTS": ["MS does this in vc++ with a suffix _s.", "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.", "Does the ", " always come before the ", "?", "Was the objective to write perverted code? <G>", "@Brian: I thought that was because they added those ", " functions later... had the functions been safe in the first place, they wouldn't have needed a variant."], "VOTES": "11"},
{"ID": 39, "ANSWERS": ["The team size was about a dozen. For C# methods we had to put a huge XML formatted function before every function. I don't remember the format exactly but it involved XML tags nested about three to five levels deep. Here's a sketch from memory of the comment.", "I've got to stop there....", "The downsides were many.", "I used a code snippet (Emacs YAS) to add this code to my methods."], "COMMENTS": ["XML formatted anything in code hurts readability. To be used at the head of every single function, thats just horrible"], "VOTES": "11"},
{"ID": 40, "ANSWERS": ["(Probably only funny in the uk)", "An insurer I worked at wanted a combination \"P\" or \"L\" to denote the scope, concatenated with hungarian for the type, on all properties.", "The plus point was we had a property called pintMaster! Made us all fancy a drink. "], "COMMENTS": ["+1 'cause now I fancy a drink too!", "\r\n ", "\r\n ", "+1 ...and to people who enjoy UK shows :)"], "VOTES": "11"},
{"ID": 41, "ANSWERS": ["It was a coding standard I did not follow myself ( got in trouble for other things, but never that ).\nWe had three 19\" monitors, so we could have two editors open to full screen and still have access to the desktop.\nEveryone else did not use comments, but used meaningful names. Extremely long meaningful names. The longest I remember was in the 80 character range. The average was around 40~50.", "Guess what, they didn't accurately describe the whole thing."], "COMMENTS": ["for(int ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime = 0; ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime < 10; ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime++) ;", "ITYM: for(int ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime = 0; ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime < 10; ThisIsAnIterativeVariableWhichWeWillIncreaseBy1EachTime+=2);"], "VOTES": "10"},
{"ID": 42, "ANSWERS": ["If I remember correctly the delphi IDE did a default indent of two spaces. Most of the legacy code for the company had three spaces and was written by the VP IT and the CEO. One day, all the programmers were talking about what we should do to make our lives easier and a contractor who knew Delphi pretty well said, \"Hey the ide defaults to two spaces does anyone have a problem with us doing this going forward for new code?\" All of us looked at each other, and pretty much thought it was a no brainer and said that we agreed. ", "Two days later the VP and CEO found out we were going to make such a dangerous change that could \"cause problems\" and instructed us that we would be using three indents for everything until the two of them could accurately evaluate the impact of such a change. Now I am all for following standards, but these are the same people who thought oo programming was creating an object with one function that had ", " of the logic necessary to perform an action, and that source control was moving the code files to a different directory. "], "COMMENTS": ["You can set the indent in the environment options!", "Ah HA!! So THATs where three spaces comes from!", "I will never understand why people hate with a passion a simple space or tab.", "+1 because I just left a job where I started under one of these programmers, management couldn't understand why working with legacy code was so time consuming: \"people who thought oo programming was creating an object with one function that had all of the logic necessary to perform an action, and that source control was moving the code files to a different directory\""], "VOTES": "10"},
{"ID": 43, "ANSWERS": ["Not quite a coding standard, but in 1998 I worked for a company where C++ was banned, in favour of C. This was because OO was considered too complex for the software engineers to grasp.", "In our C code we were required to prefix all semi-colons with a space", "I could never find out a reason for this, but after a while it did grow on me."], "COMMENTS": ["+1 for working with programmers that are afraid of OO", "Well, Linus has stated that C++ is a horrible language: ", "I'm not impressed with Linus's ranting. He sounds very idealogical and biased. I'll stick with the STL - it's never broken for me.", "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.)", "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.)"], "VOTES": "10"},
{"ID": 44, "ANSWERS": ["One that no one has mentioned is being forced to write unit tests for classes that are brainless getters and setters."], "COMMENTS": ["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.", "in that case, write yourself a script \"Generate Getter- and SetterTests\".", "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)", "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.)", "Of course not! \"The database does that.\" (actual quote from co-worker)"], "VOTES": "9"},
{"ID": 45, "ANSWERS": ["In Java, when contracting somewhere that shall remain nameless, ", " were banned. The logic? The guy in charge couldn't find implementing classes with Eclipse...", "Also banned - anonymous inner classes, on the grounds that the guy in charge didn't know what they were. Which made implementing a Swing GUI all kinds of fun."], "COMMENTS": ["I feel very bad for you.", "Perhaps ", " ?"], "VOTES": "9"},
{"ID": 46, "ANSWERS": ["The one that got me was similar to the other poster's \"tbl\" prefix for SQL table names.", "In this case, the prefix for all stored procedures was to be \"sp_\" despite the fact that \"sp_\" is a prefix used by Microsoft for system-level stored procedures in SQL Server. Well, they had their standards from an old, non-MS database and weren't about to change just because their standard might cause a stored procedure to collide with a system stored procedure and produce unpredictable results. No, that just wouldn't be proper."], "COMMENTS": ["Naming stored procedures with sp_ is also a performance hit -- MS SQL assumes that they're in the master DB, and when it can't find them, it regenerates the execution plan...", "@Roger -- thanks for the info. I've inherited my fair share of these (my own standard usp_) from other developers; good to know about the performance hit.", "It is very common in my experience to prefix stored procs with sp_ in SQL Server. I have seen it in many places. I prefix procs with proc_ and functions with fn_.", "sp was the prefix used by Sybase - long before MS SQL Server came into being (by adapting Sybase).", "doesn't it help when you see something like \"SELECT * FROM vwPatients\" to know you are referencing a view insteal of a table...that would be \"SELECT * FROM tblPatients\""], "VOTES": "8"},
{"ID": 47, "ANSWERS": ["I was told that old code should be commented out rather than being removed; in case we needed to refer to the old code (yes, the code was in source control...). This doesn't seem that bad, until major changes are made. Then it becomes a nightmare, with entire sections deleted all over the code."], "COMMENTS": ["i often do that so that no one trys to fix my fix. I have had to leave comments like \"please do not change this line, this is really the correct way to do this\" when working on a \"team\" of programmers who would consistently re-introduce bugs that I fixed, because they were sure my fixes were wrong.", "I sometimes to that actually, but I move them to the bottom. Its helpful in between commits."], "VOTES": "8"},
{"ID": 48, "ANSWERS": ["I once had to spell out all acronyms, even industry standard ones such as OpenGL. Variable names such as glu were not good, but we had to use graphicsLibraryUtility."], "COMMENTS": ["I hope you didn't use any software from GNU = \"GNU is Not Unix\"."], "VOTES": "8"},
{"ID": 49, "ANSWERS": ["I once worked on a VB.NET project where every method body was wrapped in the following ", " block:", "Those who do not understand ", " are doomed to reinvent it, badly."], "COMMENTS": ["That will be a \"guru\" who knows about all this new-fangled exception handling but still thinks in ", ". :-("], "VOTES": "8"},
{"ID": 50, "ANSWERS": ["Once I had to do a little DLL out of my team and when it was done I had to redo the job because I shouldn't have had used \"else\" in the code.\nWhen I asked why I was instructed not to ask why, but the leader of the other team just \"didn't get the else stuff\"."], "COMMENTS": ["Didn't get the else stuff...? And this guy got hired how?", "I can say he came from the Cobol age and fell down in a OO project. I guess he came thru a portal directly from the 70's... ;) I remember that I put a huge comment explaining why I did that without \"else\", I didn't want to be blamed for that hidious code.", "should have just done \"else if True\". Same function as else, and maybe the idiot can grasp that."], "VOTES": "8"}
]