Home | Forums | What's new | Resources | |
Good Code Commenting |
slobu - Aug 22, 2011 |
Chilly Willy | Aug 23, 2011 | |||
I follow the "Real Programmers" philosophy - "Real programmers never comment; if it was hard to write, it should be hard to read, and even harder to change."
|
slobu | Aug 23, 2011 | |||||
I hear that! Back in high school I wrote a platform scrolling engine in QuickBasic. It used Mode 13 (320x200 256 colors) without a buffer. To emulate a buffer I set half the colors black and XORed part of the screen. The scrolling was accomplished by copying a viewports worth of drawn (but blacked out) "tiles" until an updated set of tiles were needed. Years later I have no idea how I did it - and I have the source All fun aside I'll assume 2 things from what you said (or didn't say): * It's always best to keep it simple enough that comments are unneeded and/or redundant. * No real problem with my comment style. Thanks again Chilly Willy |
Chilly Willy | Aug 23, 2011 | ||||||||
Yeah, that old stuff is sometimes pretty baffling.
Yeah, it seems okay. Avoid "over-commenting" - I hate code where there's a three page comment for every line. Write a damn book if you want to comment that much! I mainly give an overview at the start covering things like global variable/register usage (especially for assembly code), and then basic comments where appropriate. If you use decent names for variables and functions, you can avoid tedious comments, like uint16_t xx10y3t; // this variable holds the number of cycles until the next emulator event Uh... yeah. So why not just use uint16_t cyclesUntilEvent; I've always gone for descriptive names... gives me an excuse not to comment as I'm a lazy bum. |