Wednesday, 20 April 2011

Commenting Code is like Eating Peas

Practices of an Agile Developer (Neill Alexander) (Hunt Subramaniam)
- Highlight Loc. 1786-88  | Added on Monday, April 04, 2011, 07:19 AM

Code will always be read many more times than written, so the little extra effort that is required to document your code when writing it will pay you back handsomely in the end.

When I was a kid, I used to leave my vegetables until last. At the end of my dinner I'd be sitting there with an enormous mound of peas, with my mother breathing down my neck, demanding that they be finished before I could leave the table.

I hated peas.

When I was at university learning how to program, there were people in my class who used to leave commenting code until the end. They used to write their entire computer program, then go back at the end and add comments, because they'd lose marks if they didn't provide any.

They hated writing comments.

What I didn't understand as a kid was that peas aren't so bad when you eat them in combination with the rest of your food. In fact, now I think they are delicious. I wouldn't like to eat a giant mound of them by themselves though.

No comments:

Post a Comment