Skip to content

Comment on Comment your damn code

Comments

Note that the following does not count as commenting your damn code:

    // Get the account holder currency
    $currency = $accountHolder->getCurrency();
Imagine several 10s of KLOCs where 99% of the comments are as worthless as this and most people are content with their efforts because they believe they are commenting thoroughly.

People learn this bureaucratic sort of stuff in school, where they are graded in a bureaucratic fashion.

As with all things, ROI is key. Your commenting effort is a finite resource. Expend it in the way that gets you the most value.

Those aren't comments, that's someone being lazy.

A comment should describe the why or the goal, not the how.

Personally I appreciate good "how" comments for algorithm implementations in C++, where the implementation in code isn't as clear as a (perhaps less efficient) pseudo-code version in the comments. "How" comments are just as valid as "why" comments, and the parent comment illustrates that "copy-comments giving no more information or intuition than the code" are worthless, which is why I don't have comments every 3-7 (not even every 20) lines like the submission suggests.

Two years later:

    // Get the account holder currency
    $security = $counterparty->getSecurity();
AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.