Slashdot Mirror


Comments are More Important than Code

CowboyRobot writes "I was going through some code from 2002, frustrated at the lack of comments, cursing the moron who put this spaghetti together, only to realize later that I was the moron who had written it. An essay titled Comments Are More Important Than Code goes through the arguments that seem obvious only in hindsight - that 'self-documenting' code is good but not enough, that we should be able to write code based on good documentation, not the other way around, and that the thing that separates human-written code from computer-generated code is that our stuff is readable to future programmers. But I go through this argument with my colleagues, who say that using short, descriptive variable names 'should' be enough as long as the code is well-organized. Who's right?"

34 of 1,021 comments (clear)

  1. Even more annoying... by Anonymous Coward · · Score: 5, Funny

    I used to grade student's code as a TA at my university, and I'll tell you what is more annoying than NO comments, this:

    printf("Encrypt message..."); /* print "Encrypt message..." to the console */

    and then followed by about 150 lines of uncommented spaghetti code

    1. Re:Even more annoying... by Klar · · Score: 5, Insightful

      hah I also grade as a university TA, and let me tell you what is more annoying than that... people who don't know how to indent their code, and want you to help debug it! Ahhhhh!!!!!

    2. Re:Even more annoying... by Anonymous Coward · · Score: 5, Insightful

      You know whose fault that is? The morons that mark you down if you don't comment trivial programs like Hello World.

      I actually ended up doing three introductory programming courses at college and university (overlap in curricula), and I've been marked down for not including this type of comment in all three courses.

      printf("Hello, world!\n"); /* send "Hello, world!" to the console and move to the next line. */

      The problem is that they try and teach you to write comments prematurely. When all most people on the course can write are programs like Hello World, they really can't see the use of comments and there are no good examples to give. The use of comments should come after things like functions etc IMHO, so that students can actually see how comments can be useful.

    3. Re:Even more annoying... by coaxial · · Score: 5, Funny

      I came across that with a grad student at my univ. I told him that I couldn't read his code because it wasn't indented. He said, "I was going to back and do that later." WTF? I thought that was going to be the Quote of The Day, but it turned out he wasn't done yet. I started indenting every line as I walked through a function. Seeing this, he inquired, "How are you moving those lines over?" My answer? "Tab."

      Shocking.

    4. Re:Even more annoying... by Gilk180 · · Score: 5, Funny

      An emacs post replying to an Eclipse post and you choose to point out how bloated emacs is?

    5. Re:Even more annoying... by el-spectre · · Score: 5, Funny

      As a freshman I had a professor who kept giving me shit about not having enough comments, so my next program looked something like this: ...
      a=5; //assign integer variable 'a' a value of 5
      b=2; //assign integer variable 'b' a value of 2
      print(a+b); //print to the console the sum of integer variable 'a' and integer variable 'b' ...

      and so on, for about 200 lines. Worthless commenting? Sure, and childish too... but it was amusing and I never got docked for insufficient commenting again :)

      --
      "Faith: Belief without evidence in what is told by one who speaks without knowledge, of things without parallel." - A.B.
    6. Re:Even more annoying... by Anonymous Coward · · Score: 5, Informative

      in vim, with C code, you can just do:

      gg=G

      and it will reindent a file for you....

      I hate programmers who refuse to learn about their tools.

    7. Re:Even more annoying... by T-Ranger · · Score: 5, Insightful

      Ive been in enough classes this year (well below my level.. dammit, I need the "letters") that Ive come to the conclusion that introductory programming courses are taught all wrong.

      Write 5 lines. Write 20 lines. Write 100 lines. Of useless and pointless code.

      What should be done is: Take this 1000 line programme. Add on 5 lines. Add on 20 lines. Add on 100 lines. Beacuse that would require being able to read code, too. Being able to understand what is already there is frequently more then half the battle. Saying "What the fuck does this mean?" a few dozen times is the only way to get to write comments. Being a sysadmin, rather then a full time programmer, this took me litteraly years to learn. And it was usualy "What the fuck were you doing here, brain? Dammit, one of these days were going to have to start commenting our code."

      About 6 months ago, I read through a project request on one of these ebay-for-coders sites. Language optional; 1 comment per 5 LOC, but if using Perl, 1 comment per 2 LOC.. With requrements like that you are only asking to get BS comments like "Print X to the console".

    8. Re:Even more annoying... by rve · · Score: 5, Interesting

      At work, we are not allowed to use comments in the code.

      Allowing comments would "encourage coders to use clever tricks" according to the technical director.

    9. Re:Even more annoying... by geminidomino · · Score: 5, Funny

      So tell us, since you have an inside view:

      When is Longhorn actually coming out?

  2. Gotta document that code... by TripMaster+Monkey · · Score: 5, Interesting
    From the Summary:
    ...I go through this argument with my colleagues, who say that using short, descriptive variable names 'should' be enough as long as the code is well-organized. Who's right?


    You are. No question.

    I have a saying I like to use when people (usually managers) try to persuade me to take the quick/cheap way out:


    "Any time/money you save by cheaping out now, you'll wind up having to pay back twice over on the back end."


    I've yet to see this maxim disproved, and it's just as applicable to coding as it is to anything else. Your colleagues are certainly correct when they state that the code must be well organized, but this simply isn't enough. If you don't put in the necessary time (minimal, really) to properly document your code, you'll wind up spending a lot of time trying to figure out just what you did and why. Also, even if you can remember exactly what your code is all about, the guy that comes after you probably won't...proper documentation is professional courtesy. I suppose they'll learn after they spend a few hours puzzling over a piece of old code (that's how I learned...:P ). Sooner or later, not documenting properly will bite them in the ass.

    --
    ____

    ~ |rip/\/\aster /\/\onkey

    1. Re:Gotta document that code... by Fjornir · · Score: 5, Insightful

      The canonical form of your maxim is "If you don't have time to do it right the first time, when will you find time to do it again?". The correlary is: "The problem with quick and dirty is that dirty remains long after quick is forgotten."

      --
      I want a new world. I think this one is broken.
    2. Re:Gotta document that code... by RootsLINUX · · Score: 5, Insightful

      I agree. Giving your variables descriptive names is a good practice, but it's not nearly enough "commenting". If you have a piece of code that manipulates the values of those descriptive variables with bit masks to spit out a value, how is someone supposed to know what you just did? I think the adage "you don't document your code, but you code your document" is a little extreme, but it gets across the importance of code documentation. I'm working on an open source project of my own right now. I went back to modify a piece of code that I hadn't touched for nearly 4 months, only to make absolutely no sense of what the hell I was doing there. Luckly I commented it extremely well so after reading the comments I was able to get that "Oh yeah..." feeling and make the appropriate modifications without breaking the code. Lesson: commenting code may take you some more time now, but it's going to save you a hell of a lot of time later.

      On that topic, what are some good examples of well-commented code? Rather than just see words, I'd rather see real-life applications of these practices. For starters, here's typically how much I comment my code: Allacrost source code (note: not all files were written by me, by I try to stress heavy commenting on the rest of my team)

      --
      Hero of Allacrost, a FOSS RPG for *NIX/*BSD/OS X/Win
    3. Re:Gotta document that code... by snorklewacker · · Score: 5, Insightful
      You are. No question.

      Hello. I question. Look, if you need comments to explain the code flow because your method spans four screens and has six levels of conditionals in two levels of loops, all the comments in the world won't help you.

      Especially if you change the code and now the comments are wrong

      I have had the joy of maintaining lovingly commented code with all these huge blocks at the start showing what args get passed and what happens, and I can't understand a god damned thing about what it's doing, because the code all looks like
      (void *((ebuf->qs) > VRT_FBUF) ? etranf(&q) ...
      All generalisms are wrong.
      --
      I am no longer wasting my time with slashdot
    4. Re:Gotta document that code... by rkcallaghan · · Score: 5, Insightful

      Sooner or later, not documenting properly will bite them in the ass.

      Actually I have found that more often than not, not documenting properly only bites someone else in the ass.

      This is likely the source of the problem, and the least likely to change. I suppose it could be part of the QA process to check for notation on code, but I somehow suspect that with programming jobs on a one way trip to Bangalore that readability it secondary to "works cheap."

      ~Rebecca

    5. Re:Gotta document that code... by spammacus · · Score: 5, Funny

      All generalisms are wrong.

      Isn't that a paradox? :)

    6. Re:Gotta document that code... by jesup · · Score: 5, Interesting
      comments can lie
      I worked with a programmer who disliked comments so much he'd remove them before looking at a function. Ok. So I wrote some code and he came to me and said "why do you have an empty else case?" I was puzzled, then realized that I'd written something like this:
      else
      {
      /* we don't have to do anything in the else case because of x y and z */
      }
      where x y and z would be non-obvious to anyone who wasn't fully immersed in this code. He's run it through a filter that removed all comments. He was a genius programmer - but wrote code that almost no one else could ever maintain. Tons of reliances on edge conditions without comment, reuse of generically-named variables (1 and 2 character names), tricky (but efficient) algorithms. So far as I know, I was the only one there ever to manage to really grok his code, and that required days of immersing myself.

      x = x++; // add one to x
      is obviously not useful.
      // Test FU_E (End bit) after FU_A/FU_B test! If there's a gap, do not consider
      // hitting the End bit a marker to stop - continue until we see another
      // packet/timestamp (in which case we return TRUE), or until we are
      // at the end of the buffer (in which case we return FALSE and keep
      // hoping to assemble it).
      if (((*curr)->GetPayload()[1] & FU_E_BIT) && !gap)
      break; // no error in fragment
      // if there's a gap we still won't return true unless
      // we find a non-fragment packet (or one from another fragment!)
      This is an example of a useful comment - and yes, it has to be maintained if the line of source were to change. I chose that at random; there are better examples - such as explaining what the edge cases are (especially if not handled), and under what circumstances they would become relevant, and how they could be dealt with then.

      Please excuse the incorrent indenting above; "<ecode>" doesn't work exactly like 'pre'

    7. Re:Gotta document that code... by skraps · · Score: 5, Insightful
      That comment is a good match for the code it is with. I never write comments like that unless dealing with a 3rd party interface, or something else that is a brick wall I can't refactor across, and there is something very quirky or unusual about it. The 'if' in the last snippet you quoted is very complex, and I would probably try to decompose it into a few functions and/or objects as necessary to make it clear what is happening. For example, you could start by replacing the 'if' with:
      if(message.is_complete())
      break;
      This clearly expresses the intent of the code you quoted (assuming I understood it correctly). Here, I've created a 'message' object to encapsulate some of the logic. The entire loop may be changed to look something like this:
      while(!message.is_complete())
      {
      packet_t packet=connection.get_next_packet();
      message.receive_packet(packet);
      }
      Now, the "is complete" decision making is abstracted to the "message", which seems to me the right place for that responsibility. Another thought is that the [1] should be changed. I'm guessing that you are referring to the second byte of the received packet, and using it as a flags field of some kind. If that is the case, why not go ahead and make a struct that represents the header layout, and reference the flags through a bitfield in the struct? If you do that,
      (*curr)->GetPayload()[1] & FU_E_BIT
      Becomes
      (*curr)->header->flag_end_of_message
      ...which seems clearer to me.

      You could continue along these lines, and get to a point where it would be obvious what the code does. The comment in that snippet also addressed "why", in addition to "how". I would move the "why" explanation into a document that defines the protocol.

      --
      Karma: -2147483648 (Mostly affected by integer overflow)
    8. Re:Gotta document that code... by slashdot.org · · Score: 5, Insightful
      Here's what my version would look like:
      //---
      // TODO: gracefully handle wrap-around of SDL_GetTicks()
      // not implemented yet because it only happens every 40 years
      //---
      tmp = last_update;
      last_update = SDL_GetTicks();
      tmp = last_update - tmp;
      fps_millis_timer += tmp;
      fps_counter++;
      My philosophy is that:
      1) production code is not a tutorial of the C(++) language. It's okay to assume the reader knows their stuff. A bad example:
      tmp = last_update; // tmp = last update time
      2) production code is not documentation on the APIs that it uses. APIs have their own documentation, the reader either is familiar with it, or can find documentation. A bad example:
      last_update = SDL_GetTicks(); // now
      If the API is only used in one file, then you could point at the documentation right where the header is included. If it's used on a project level, then it should be pointed to at the project documentation.
      3) comments are just as much about why you didn't do something a certain way as it is about why you did do something a certain way.
      4) the obvious; name your variables correctly. Instead of:
      fps_timer += tmp; // Increase our fps millisecond timer
      use
      fps_millis_timer += tmp;
      5) if you are implementing using a spec, somewhere in the top of the file describe the revision of the spec. Additional comments can describe the section of the spec that they relate to.
      For example:
      // Init GDT, see section 6.3.1
      virtual_machine.gdt.base = base;
      virtual_machine.gdt.limit = limit;
      6) NEVER put actual values in comments. For example:
      com1.baudrate = 9600; //set baudrate to 9600
      The code already shows the actual value, and all too often the comment doesn't get updated.
      Sometimes it's okay to list the possible values:
      out_p16_d8( base + CSR, 0x66 ); //0x61 = 1x, 0x62 = 2x, 0x66 = 4x, other val illegal
      but I only prefer that when this is the _only_ place where it is used. Otherwise you'd use enums and/or refer to the documentation section/page
      7) write top level documentation to explain what the software is actually supposed to do. It's amazing how often this is missing. Write one bloody page that describes to a programmer that doesn't know ANYTHING about the software what the hell it's supposed to do, and how it's accomplishing this. It also helps tremendously if every file has a little description in the header. And I'm not talking about what license the code is distributed under.
  3. Comments more important? by Rollie+Hawk · · Score: 5, Funny

    Has he read the ones here?

    --
    Before any liberals are tempted to mod up one of my comments, a word of warning: I'm actually making fun of you.
  4. Something i notice by bmajik · · Score: 5, Insightful

    i do a lot of code reviews at work and nothing makes me happier than good comments.

    but just putting a bunch of blocks of comments that are like "get customer", "build record", etc are basically useless. If you use programming by intent then its more or less obvious that the code

    GetCustomerFromDatabase(foo)

    is going to do something with a database and get a customer. a comment telling me that is useless.

    what i like to do is write a few paragraphs of text at the top of a function. it explains my general approach, why im doing certain things the way i am, why im not doing other things, and why the function even exists.

    essentially the comments should be enough that anyone that knew the problem space ought to be able to read them and come up with more or less a similar implementation.

    then, in the body of the method anytime i do something that i feel isn't completely obvious, i put a 1 or 2 liner infront of, i.e. "we have to do this because zergs are sensitive"

    the end result of all of this is that code reviews can see what you were thinking at the time the code was written.. and you're documenting assumptions about the problem, the apis, your understanding of the language, etc, all right in the code. it makes finding errors pretty easy.. someone that can't even read source code can read the comments and get an idea of the correctness of your approach.

    --
    My opinions are my own, and do not necessarily represent those of my employer.
  5. Nah by Anonymous Coward · · Score: 5, Funny

    Variable names should be proportional to the size of their scope within the code.

  6. New Techniques and Better Programmers. by X-rated+Ouroboros · · Score: 5, Insightful

    If the comments are clear, a better programmer than you can come along later and say "What the hell was this guy doing?" and then replace your lines of fumbling crap with much cleaner/clearer code.

    It's the difference between being able to see what you were trying to do vs. figuring out what you actually did.

    Call it "Intent Oriented Programming" if you want.

    --
    Simple Machines in Higher Dimensions
  7. Uhh... by PrimeWaveZ · · Score: 5, Funny

    UsngShrtCmtsIsOftNotEnghAsOneMyNdToReWrtShtInTheFt r.

  8. Raskin by kebes · · Score: 5, Informative

    JEF RASKIN, professor of computer science at the University of Chicago, is best known for his book, The Humane Interface (Addison-Wesley, 2000), and for having created the Macintosh project at Apple. He holds many interface patents, consults for companies around the world, and is often called upon as a speaker at conferences, seminars, and universities. His current project, The Humane Environment (http://humane.sourceforge.net/home/index.html), is attracting interest in both the computer science and business worlds.

    For those who don't know (which apparently includes whoever is in charge of the linked article), Jef Raskin passed away this february. You can view the official press release, or read more about his contributions to computer science. I don't know when the article was written, but it seems it should mention that Raskin has passed away. In any case, his advice about commenting is good, just as his advice on user-interface design has always been lucid and helpful.

  9. Indeed by screwballicus · · Score: 5, Funny
    I was recently reading through some code I wrote ages ago and hadn't looked at in years, and wondering...dear god, what's this confused mess trying to do?

    Imagine my relief when I came upon a helpful comment:

    What the hell was I thinking when I wrote this?

    All it took was one comment to put my mind to rest: no, it's not just me being stupid in the present. This code seemed this terrible back then, too.

    Comments save the day once again.
  10. Comments Should Reflect Intent by Bob9113 · · Score: 5, Informative
    I found the following in some production code, which quickly and concisely demonstrates why many comments are highly questionable:
    /** Always returns true. */
    public boolean isMagilla() {
    return false;
    }
    That's the core problem with many comments, but it can be avoided. Comments are good when they state the intent or business case for a block of code, acting as a guide to the meaning of a block for subsequent developers. They are bad when they profess to know the actual outcome or implementation of a block; only the code itself can accurately reflect the state of the code.

    The above would be far more useful like this:
    /** Tells whether this instance meets the magilla criteria. */
    public boolean isMagilla() {
    return false; // currently, no MyClass meets the magilla criteria.
    }
    Now the intent of the method is clear, and anyone coming along who wonders why it's hard coded will know under what circumstances they should change it to a formula (namely, if MyClass becomes capable of meeting the Magilla criteria).

    Comments can be good, but they should always be a guidepost to the intent of a block of code, and not attempt to explain how the code achieves that goal.
  11. Quality not quantity by MagikSlinger · · Score: 5, Interesting

    Having RTFA, I can see what he's trying to get at, but as someone who has (unfortunately) found himself spending most of my 10 year career in programming cleaning up other people's poop. At first I thought it was because I must have done something wrong that I kept ending up being assigned this work, but as I came to realise, it was because I make the code better than I found it and I have a knack for fixing stuff other people give up on. I also had silly managers who assign work to the people least qualified to do it.

    At any rate, some observations:

    1. 20 lines of comments "documenting" your code before you write it (or even after you write it) is far less useful than writing the code COHERENTLY and CORRECTLY in the first place.

    Last month, I had a 1200 (yes 1,200) line method with huge blocks of documentation before big pieces of code. I still can't quite tell you what it thought it was doing. The code was a for loop wrapping around code to handle 3 different and mutually exclusive situations. Instead of identifying which of the 3 situations it was and creating a method for each situation, the person just stuffed it all in with lots of comments documenting everything the article's author said. The code was still unmaintainable.

    2. Comments are useless unless they are kept up to date

    Part of the reason that code was so difficult to figure out was because most of those big verbose documentation comments referred to a completely different implementation. After the programmer had written the first case, she encountered some other bad cases and eventually had to completely change a block of code embedded in this 1200 line for-loop. The code was now correct, but the comments no longer had anything to do with that block of code.

    3. Don't be clever when you can be clear

    I have made a solemn vow to hunt down and hurt anyone who puts "clever" code in my project. I am so sick of trying to figure out what some obfuscated piece of code in C, C++ or even SmallTalk is doing. And find out it was just a "clever" way of doing something pretty straight forward like iterating over a list. There was no speed gain from the clever trick, and the code wasn't even a bottleneck to begin with. *sigh*

    4. If you don't know how to solve the problem, write some experiment code in a separate app to figure it out. Then take the time to do the "right" thing in the production code.

    3 days from final for a video game. The CD streaming library for the Sony Playstation was making this strange "hic-up" sound at rare moments. By this time, the original author of this code has long since gone to another company. So I plunge into the code and found that the original programmer didn't know how to write streaming code so he created this hack of a hack of a hack of a test (ad nauseum). The code was programmed by accident, not design. No amount of comment before coding could help this. If the author had dumped the code, wrote documentation describing everything he learned then wrote the code, things would have been a lot better.

    5. Unrelated to comments, but use variable names that make sense. Don't name them arbitrarily or to amuse yourself!

    That CD sound streamer code I mentioned above used quirky names for variables. Can you tell what "little_ninja" is supposed to be just from the name? When I confronted the coder about this quirk of his (in another library he wrote), he got all huffy and didn't understand why people didn't appreciate his little puzzles or his sense of humor. It galls me he still earns a paycheck in the industry.

    --
    The bitter lessons of a veteran coder: http://bitterprogrammer.blogspot.com
  12. Top Ten Code Comment Do's List by Anonymous Coward · · Score: 5, Insightful

    1. Comment each function
    - Function name
    - what it does
    - parameters
    parameter name - what is is for and any restrictions on it (i.e., must not be null)
    - return value (all possible return values)

    2. Add comments to each file you modify so that over time, the file becomes better documented

    3. Add ASSERT() like comments and ASSERT() or equivalent to your code

    4. Use dividing comments like a line of dashes to seperate blocks of code

    5. Put in a '?' comment for code that you do not understand (good for function headers)

    6. Avoid stupid naming schemes for your local variables since that makes it harder to comment

    7. Review your code for both logic and comment completeness after you code it before committing it to version control

    8. Tag your bug fixes, code enhancements with a comment followed by a dash, date, and your initials. This is essential for large projects or for anything you will be working on for more than 6 months.

    9. Format your comments so that multiple line comments line up on the left hand side (increases readability)

    10. Don't count on java doc or equivalent as being good enough code documentation.

    1. Re:Top Ten Code Comment Do's List by dooglio · · Score: 5, Interesting

      1. Comment each function
      - Function name
      - what it does
      - parameters
      parameter name - what is is for and any restrictions on it (i.e., must not be null)
      - return value (all possible return values)

      ****

      I really hate having parameters documented in a comment block above the function declaration, because it seldom gets updated when the function signature itself is changed.

      I worked with a guy who used to format his functions like this:

      void my_func( // My function does foo
      int arg1, // arg1 documentation
      char * arg2, // arg2 documentation
      ...
      )
      {
      // Function guts go here
      }

      The nice thing about this method, although the "look" of a function is broken up, is that when you add or change parameters, the programmer is a lot more likely to change the documentation as well.

      When you're under the gun to get the code out, the less the developer has to do to change the docs, the more likely it is they will be changed.

    2. Re:Top Ten Code Comment Do's List by HomeworkJunkie · · Score: 5, Informative

      We comment all functions and classes using the Doxygen format. This means that the comments can be used to generate HTML, PDF or man pages for the functions and classes. It will also generate call trees if required. Very useful.

      --
      "Why take life seriously, you're not coming out of it alive anyway."
    3. Re:Top Ten Code Comment Do's List by Wavicle · · Score: 5, Funny
      * Oh man... I'm so tired of typing these numbers!

      You should have written a function to generate the list of numbers for you:

      /*
      * Function: num_list
      * Purpose: Returns a list of positive integers greater than one
      * Input: x, the largest positive integer in the list.
      * Possible return values: "2", "2, 3", "2, 3, 4", "2, 3, 4, 5", "2, 3, 4, 5, 6", "2, 3, 4, 5, 7", "2, 3, 4, 5, 6, 7, 8", "2, 3, 4, 5, 6, 7, 8, 9", "2, 3, 4, 5, 6, 7, 8, 9, 10", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19", "2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20",

      * Hmmm, I think I need a new function to generate the comment for this function...
      */
      --
      Education is a better safeguard of liberty than a standing army.
      Edward Everett (1794 - 1865)
  13. Re:What do you guys think of the following code? by natrius · · Score: 5, Funny

    Please don't post my code on Slashdot.

    Come see me in my office.

    - Your Supervisor

  14. here's some Pretty Evil Shit - Re:Even more annoyi by Fubari · · Score: 5, Funny
    Here is an example of some Pretty Evil Shit:
    I want to laugh when I read it.
    Some of it is funny.
    Some of it is just scary.
    The human mind can be a freakishly messed up thing.
    http://mindprod.com/unmaindocumentation.html
    It is part of a larger essay about writting crappy code.
    Anybody that even comes close to software development
    should check it out.

    --- begin excerpts ---
    Avoid Documenting the "Obvious" : : If, for example, you were
    writing an airline reservation system, make sure there are at
    least 25 places in the code that need to be modified if you were
    to add another airline. Never document where they are. People who
    come after you have no business modifying your code without
    thoroughly understanding every line of it.

    Units of Measure : : Never document the units of measure of any
    variable, input, output or parameter. e.g. feet, metres, cartons.
    This is not so important in bean counting, but it is very important
    in engineering work.

    As a corollary, never document the units of measure of any conversion
    constants, or how the values were derived.

    It is mild cheating, but very effective, to salt the code with some
    incorrect units of measure in the comments.

    If you are feeling particularly malicious, make up your own unit of
    measure; name it after yourself or some obscure person and never
    define it. If somebody challenges you, tell them you did so that
    you could use integer rather than floating point arithmetic.

    On the Proper Use of Design Documents : : When implementing a very
    complicated algorithm, use the classic software engineering principles
    of doing a sound design before beginning coding. Write an extremely
    detailed design document that describes each step in a very complicated
    algorithm. The more detailed this document is, the better.

    In fact, the design doc should break the algorithm down into a hierarchy
    of structured steps, described in a hierarchy of auto-numbered individual
    paragraphs in the document. Use headings at least 5 deep. Make sure that
    when you are done, you have broken the structure down so completely that
    there are over 500 such auto-numbered paragraphs.

    For example, one paragraph might be: (this is a real example)
    1.2.4.6.3.13 - Display all impacts for activity where selected
    mitigations can apply (short pseudocode omitted).
    then... (and this is the kicker) when you write the code, for each of these paragraphs
    you write a corresponding global function named:
    Act1_2_4_6_3_13()
    Do not document these functions. After all, that's what the
    design document is for!

    Since the design doc is auto-numbered, it will be extremely difficult
    to keep it up to date with changes in the code (because the function
    names, of course, are static, not auto-numbered.) This isn't a problem
    for you because you will not try to keep the document up to date.
    In fact, do everything you can to destroy all traces of the document.

    Those who come after you should only be able to find one or two
    contradictory, early drafts of the design document hidden on some
    dusty shelving in the back room near the dead 286 computers.
    --- end excerpts ---