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

I can't express how many times I've seen code with comment block boilerplate at the start of every method. And nothing filled in. Its really more common that the other kind.

So sure, we all know its great to document. The challenge is figuring out how to get it done. Given that we're all in a hurry, mean well but think we'll get back to it.

It feels like you're doing something when you paste in all those blank comment blocks. But soon you don't even see them, since first off they're usually blank, and second when debugging you're looking for the code not the comments, since if it all worked like its commented then there'd be no bugs.




>since if it all worked like its commented then there'd be no bugs.

Unless it is no longer supposed to work how it was originally written and commented. Software lives and evolves over time. All too often comments go stale. When the Big Bug Day comes, many hours will be wasted on such legacy comments.


At some of the more orderly places I've worked, we put dates on comments.

Also, whenever we made a change, we put a comment (at the top of the class, function, method or whatever is changed), also timestamped, with a reference to the change request ticket (or equivalent), and a summary of the change.

Old comments were deleted if necessary (you could always look them up with a diff on the source control)

Said ticket also had a reference to the code file :) so you had 100% traceability.

The downside being of course it was all very bureaucratic, but there were legal requirements to fill and it was a sensitive, finance sector company. That setup probably wouldn't work for a fast-paced startup :)


As I understand it, the difference here is that the documentation is actually tested automatically. I believe Python has a tool like this too.

Edit: or maybe not, I can't see mention of it on tomdoc.org. However the format lends itself to that.

For contrast, the D language allows inline tests.




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

Search: