Jump to content
  • Advertisement
Sign in to follow this  
caseyd

Commenting Style

This topic is 4435 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm interested in hearing about how everyone else comments their code. I personally put a comment at the top of each file describing what it is, and if it's a class definition, I describe what the class is used for. Above any functions I place: /* ==================== function name notes ==================== */ I usually only put comments in methods if there is something going on that may not be obvious. I also add little one liners at the end of a class definition or if I have nested control loops, at the end of each larger block. Just curious as to what other people do.

Share this post


Link to post
Share on other sites
Advertisement
The little commenting I do usually consists of a brief // comment right before a chunk of unusual code. I also use TODO: and HACK: prefixes to mark incomplete/bad code. I like to keep the code really compact, concise, and self-documenting whenever possible, sometimes maybe to extremes.

Share this post


Link to post
Share on other sites
Mostly I just use the //. If I need to write a bunch of stuff I'll use the
/*

*/

but that is rare. A lot of the times I don't really comment til after I'm reading back over things and I'll think "I better put something in here about this" and even then it's just the simple // Description

Share this post


Link to post
Share on other sites
Many of my comments are several lines long, explaining the principle behind the code. I used to write a header of comments above the implementation of every function, but as I got more experienced I discovered that most of the funcions were self-explanatory and no comments were necessary. So now I just put a line of //----------... between the implementations, and the comments, if any, go in the header file.

I also use the // TODO: and // HACKHACK: prefixes.

Writing a brief comment above an unusual piece of code goes without saying.

Share this post


Link to post
Share on other sites
I'm with the Doxygen guys. I've been using it for nearly 6 years now. I like it a lot.

Share this post


Link to post
Share on other sites
using /* */ is evil!

a true story:
one day i was getting a crash in the SDL library, so i d'led the source, compiled it and got it working, with the crash still.

So i had to find the bug, which could have been any where, so the only way to isolate the problem was to comment out blocks of code.

now when every line, and every function has a /* */ style comment, and you want to use do do a /* */ to comment out slabs of code, your life becomes hell! it took me many hours to remove thier comments.

Eventually found the problem and vouewd only to use /* */ for commenting out blocks temporary!

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!