Since the last post, I''ve changed my commenting style a little again based on the doco in Code Complete. Basically I now use older C style blocks as you can expand them without worrying about comment symbols for each line.
The format that I originally posted with was loosely based on the the style of ... ? Chris Hargrove a coder at 3D Realms I think. He used to run a column over at loonygames on programming.
For those that haven''t yet read Code Complete and have been commenting on when to comment (
sounds like another recent thread), the gist of what the discuss in Code Complete is to comment the code BEFORE you write the code. The comments should also be language independent, english(or whatever) representations of what your doing. In doing this you end up writing mush simpler and better structured code. Then once a routine is complete in comment(they call it PDL) you slip the actually code in to the routine.
To me the first time I heard this I thought "sounds too slow", "takes too much time", "can''t write comments as you don''t know how the code will turn out".... There were all VERY lame statements on my part. I decided to give this a try anyway... and... I LOVE IT. I found that freeing my mind from worrying about the minor details of the language allowed me to better plan the function to do what it was meant to. My code is now better structured , easier to read, and best of all written with FAR fewer bugs, esp. the larger bugs that you often don''t notice when your twiddling bits. But how long does it take? Well pre commenting takes me a little time to do, it is offset however by the fact that my code is now faster to write as I know ahead of time what I''m doing but, the big benefit''s come from not pissing about debugging the code as much.
The other two cool things I''ll mention that I''ve recently taken up after reading eh book that have had a large improvement on my coding productivity are no compiles until code is complete and running all code through a debugger line by line. Not compiling the code until a function is complete is something that you can only really do once you know the language moderately well but once you start doing this you''ll find yourself concentrating on quality rather than speed of your coding. I had also reduce my stress level ''s for some reason.
Debugging ALL code line by line to make sure that it actually does what it''s meant to (as opposed to just producing the result you expect) turned out to be a great idea. Not only did it catch bug that might not have arose for some time but if found that my defensive coding improved as I could see line by line where ''other'' things might go wrong.
So, if you don''t have this book yet GET IT. Sell you sister and get the book. Have a look at gamedev''s book reviews, nobody has given this book less than the highest score possible. That says something.