Hacker News new | ask | show | jobs
by andrewcooke 4960 days ago
ok, so i wrote some code yesterday. i didn't write it expecting anyone to read it (i mean, not critically on hn), and it's not as good as i would like, but it has no comments (apart from at the top of the file explaining how to use the program).

so, people who are saying "just comment it" - what would make a big difference to this code?

https://github.com/andrewcooke/amcl/blob/master/amcl.py

2 comments

First of all, I have written only very little Python in my lifetime.

Second, I thought the code was pretty clear except for the refresh function in the TextLine and BarLine classes. The only other thing that could use a comment was the track_data function to show what the string looks like that is being returned.

PRESETS could use a brief explanation. Even after reading all of the code I'm not entirely clear on what it's being used for, and there's no hints to its purpose where it first appears.
thanks for the comments guys. i often work alone so it was interesting to check whether my standards match others. i agree on the points identified as being the weaker parts, and i'll try fixing things (not sure if that means re-writing or adding comments) when i have a moment.

[if this were paid work i hope i would have done something a little better, but that's easy to say...]

but also, in the context of this thread, maybe this shows that code doesn't need comments as terribly as some people seem to think.

my own opinion is that generally if you need a comment you should try to improve the code first, but that sometimes they can be useful. unfortunately that's a rather pragmatic approach that doesn't make for great blog posts or discussion flame wars...