I don’t read code comments

They are wrong.

Misleading at best.

Reworking parts of Drizzle (which came directly from MySQL) it can get painfully obvious. Things like “afaiu” and “???” appear in more than one place (that is if the comment isn’t just obviously wrong).

A comment merely states what one person thought the code did at some point in the past. It has no relation to what the code actually does now.

7 thoughts on “I don’t read code comments

  1. Perhaps this issue simply distills down to comments in the MySQL source code suck? If the comment doesn’t express what the item actually does, then it means someone neglected to update the comment :).

    So perhaps the argument should be “Comments that aren’t done right are useless and otherwise suck”

  2. I’m not a developer, but most comments I’ve read are useless — they’ve either been too basic (“loop through x from 1 to 20” …. yeah, duh!) or they’re completely abstract (“process data”).

    The best comments are the ones that specify what the developer *intended*. ie, “If x=y it means there’s a solar eclipse, so look at it through a pin”. Then, if the code doesn’t *agree* with that, you know what the original developer *intended* that crappy mess to be.

  3. As someone who spends way too much time debugging MySQL source that I wish has more comments, I couldn’t disagree with you more. I don’t think that implementations change as rapidly as you suggest. But our assertions about the utility of comments can be verified. First find the comments (hard to do in some source code), then determine their accuracy. Comments are useful to me even when they have occasional errors. This is not a binary decision.

  4. “A comment merely states what one person thought the code did at some point in the past. It has no relation to what the code actually does now.”

    Well maybe commenting implementations has this tendency. But really, the MySQL server code more often than not does not even bother to document the purpose of functions and methods, their arguments and return types. The InnoDB code is a very welcome relief in this respect.

  5. I’d say that a lot of the code should be a lot clearer… something we’ll hopefully get with Drizzle…

  6. Stewart’s assertions must be about Driizle source rather than original MySQL source as the original source doesn’t have many comments.

  7. Sometimes comments are crap – agreed.
    But simply saying you don’t read them and that they are useless is even more silly. I comment my code. I try and explain what conditional controllers I am using, why, and what the results mean along with what action (at a high level) each part is doing.

    Maybe amend it to “I don’t read bad code comments, but I adore them when they are clear and concise.”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.