News for hackers. Stuff that matters.
Re:Reducing technical debt by valuing comments as much as code by JamesBarney on Tuesday January 31, 2023 @06:39PM (#34604002)
// Adds two numbers together function Add(int a, int b) { return a - b; }

is even less clear.

Re:Reducing technical debt by valuing comments as much as code by rightbyte on Tuesday January 31, 2023 @07:03PM (#34604232)
Not really. You clearly see that the intent at some point was to add two numbers, and not some fiction about ADD the diagnosis or what ever.
Re:Reducing technical debt by valuing comments as much as code by ablob on Tuesday January 31, 2023 @07:46PM (#34604664)
So which one is right, the name of the function (the comment), or it's implementation?
Re:Reducing technical debt by valuing comments as much as code by rightbyte on Wednesday February 01, 2023 @11:43AM (#34613158)
Rethorical question? You can't know that without looking on how the function is used.

You at least know something is strange from the comment.

Re:Reducing technical debt by valuing comments as much as code by alpaca128 on Tuesday January 31, 2023 @07:12PM (#34604323)
Sure, but I don't think anyone would call this a useful comment - it's exactly the kind of comment which should be avoided.

Comments don't need to describe what the code does, but if there's an unexplicable line which handles an obscure edge case you better add a comment or even you won't remember why that line exists 3 months later.

Re:Reducing technical debt by valuing comments as much as code by TedDoesntTalk on Tuesday January 31, 2023 @07:35PM (#34604557)
Because comment is out-of-date. That’s technical debt. The comment is not the problem: the developer not updating it is.

You wouldn’t leave out-of-date code in a system, it would cause bugs. Why would you leave out-of-date comments? Oh, because you don’t like to write. Your strength is math and code, not writing. Now we get to the heart of the matter and not some ruse like “code is self-documenting.”

Re:Reducing technical debt by valuing comments as much as code by wkdneidbwf on Tuesday January 31, 2023 @09:46PM (#34605672)
i mean, this is actually perfectly clear—in the sense it’s clearly and obviously a mistake either with the comment and function name or it’s implementation. the example isn’t great because it’s devoid of context that might indicate what specifically is wrong with it.

there are many standard means that should catch this: code reviews, unit tests, etc.

this stuff can obviously still sneak through, but i don’t think this is a good example of what folks are generally talking about here.

Re:Reducing technical debt by valuing comments as much as code by ac50hz on Wednesday February 01, 2023 @02:35AM (#34607591)
+10

Comment review is as important as code review.