Tuesday - March 18, 2003
misleading comments

Don’t get suckered in by the comments — they can be terribly misleading. Debug only code.

– Dave Storer

Consider a developer named Chuck. To figure out how to use an algorithm, Chuck writes comments to describe each step. A few days later, he fixes a bug in his algorithm, but forgets to change the comments. A few weeks later, another fix is required, resulting in more changes to the code, but the comments remain the same.

A few months later Gary, another developer, is tasked with adding a feature to Chuck’s code. After reading the comments Gary starts adding the new feature and can’t figure out why it doesn’t work.

In an ideal world, comments would always correspond with code, but experience shows that the world is not ideal. If you’re maintaining code and see comments that are no longer correct, by all means fix them, but it’s good advice to only follow the code. Comments are secondary in most developers’ eyes, and when they’re fixing a problem, they test the program, not the comments.







# of readers
- home
meta
comics
news links
other links

about me
blog archives
docs
entertainment
experiences
funny lists
humor
intellectual
interests
mefi
music
opinions
photos
web designs
tools
webmaster help

Sign up
Enter your e-mail address to be notified of new posts



Search blog archives

Calendar
March 2003
S M T W T F S
« Feb   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  



Random quote
(View all quotes)
"It is amazing how much people can get done if they do not worry about who gets the credit."










Licensed under Creative Commons
(?) Choose theme:  X X X X X X


Loaded in 0.1470 seconds