Friday, October 1, 2010

//I feel like my commentary is ignored by the compiler.

Thanks to Casey for this link.
It's a collection of some of the most memorable comments found in software code.
For those that don't know what that is, you can insert comments into your computer program by prepending your comment text with some predefined characters, such as "#" for shell scripting or "//" for C and Java programming languages.
Text that begins with such character strings will be ignored when your code is run or compiled into an executable.
Comments help future programmers who might need to maintain your work by either explaining what your code is supposed to do, assumptions you've made, why certain functions are necessary, temporary workarounds, etc.
For the programmers themselves, commenting also allows an outlet for some imagined social connection or pent up cynicism, creativity, and humor.

Like this:
//
// Dear maintainer:
//
// Once you are done trying to 'optimize' this routine,
// and have realized what a terrible mistake that was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 32
//


and this:
// I dedicate all this code, all my work, to my wife, Darlene, who
// will have to support me and our three children and the dog
// once it gets released into the public.


and also this:
doRun.run(); // ... "a doo run run".

and finally, my favorite, which I might use in my own work to prevent other engineers from changing my code in some misplaced fit of "I bet I can do this better...":
// The following is autogenerated, do not edit.
// All changes will be undone.

1 comment:

  1. On the topic of code comments:

    http://www.kuro5hin.org/story/2004/2/15/71552/7795

    Although you have probably seen this before :)

    ReplyDelete