Hacker News new | past | comments | ask | show | jobs | submit login

No need to make things personal.

Personally, I’d agree with your example. But does this apply to all other situations? Often documentation comments can be very useful




I'd definitely agree here. There's a lot of things that cannot be expressed in a language, and need comments.

Even for e.g. get_height, does it make a DB call? Is it expensive and shouldn't be called in a tight loop? Can it ever return 0?


You're making the case against comment guidelines: It's poor engineering to resort to a comment to tell you all that.

if get_height returns a simple value, then it "smells" like it should be a simple getter.

So regardless of your comment, people will use it exactly like that and get burnt. Your comment only helps once they're already suffering enough to go digging for why things are so slow.

If the operation needs a DB call it should be exposing a way to handle the infinitely higher likelihood of failure with something like a result type, and it probably shouldn't be a simple blocking call

-

No one is saying you should never have comments by the way, but pydoc-style guidelines where you're encouraged to fill out a template end up with terrible signal to noise.

Comments should be seen as an absolute last resort and a liability.

The only parts of comments that can be automatically refactored are the absolute least useful ones. Things like intent aren't magically be pulled out and updated automatically (yet), so you're now putting the onus on every single person who ever touches that code again to keep your comment up to date, otherwise it's can end up worse than nothing.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: