Commenting source code

I hate when I look back on a block of code I wrote and it’s so complicated that I have no hope of understanding it.

But then next time I find myself writing a block of code that I know when I look back on it I won’t have any hope of understanding it, I say “pshaw… who cares? If I really really need to, I’ll figure it out”.

Also, part of my rationale is that it’s usually a small function, and it’s meant for a specific purpose. So it doesn’t matter how it works, all that matters is that it works. And given that it works just fine, I won’t be testing it and trying to debug it any further, so it might as well take up as little space as possible (while still conforming to some plausible stylistic guidelines).

Contrast this to source code in some public projects I’ve seen, where each line of code is preceded by one or two lines or three lines of explanatory comments, even when a trivial operation is performed. The PEAR source code is like this. I guess that’s helpful when collaborating on an open project.

This entry was posted in Uncategorized by . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>