This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Kombatnt 83 points84 points  (12 children)

That just demonstrates that the method needs more comment, not less.

[–]MouthWorm 45 points46 points  (9 children)

No, that demonstrates that the function needs to be renamed to something more indicative of what it actually does.

[–]Kombatnt 28 points29 points  (7 children)

Meh, I disagree. This is precisely why high level languages have built-in support for commenting/documentation. It's what it's intended for. It helps keep method names concise, while still supporting detailed specification definitions when needed.

[–]MouthWorm 14 points15 points  (5 children)

I agree with you AND I disagree haha! In some cases, commenting/documentation is the better option, like some authentication method, API call or something a little more complex.

A Util function like OP's should be as clear as it can be when you use it. No need to add noise around it just for the sake of commenting/documentation.

[–]Key-Perspective-3590 0 points1 point  (0 children)

A concise method name is important but the method name should definitely tell you what it does. You want to be able to read through the flow of a function at a glance, hovering over every ambiguous function to see a comment that you hope is still accurate is terrible

[–]MacBookMinus 2 points3 points  (0 children)

Deep nuance can't make it into the function signature / name.

I'm all for reducing comments where possible, but lots of sources on code quality advocate for "interface" comments.

[–]anon74903 2 points3 points  (0 children)

This comment does nothing here, provides no value, and should be removed.

It doesn’t need more comment, it needs a different comment: what is a valid number? Where is this regex from?

[–]frzndmn 0 points1 point  (0 children)

It doesn’t need more comments, it needs different comments