Which comment type do you prefer?
Also, when do you add comments to your code (if you do)? Do you add them whilst you're coding or do you go back and add them afterwards?Code:// This type OR /* This type */
Which comment type do you prefer?
Also, when do you add comments to your code (if you do)? Do you add them whilst you're coding or do you go back and add them afterwards?Code:// This type OR /* This type */
Depends - if I'm just making a program to test something, I don't comment. If I'm planing to give it out to someone, I will comment some parts. I like doing this:
Code:/**************************** Function name Function description ****************************/ ret functionname() {}
Do not make direct eye contact with me.
I use /* */ for comments outside function bodies, usually stuff like:and // for comments inside functions.Code:/* * class Foo * explain what it does here */
I use them both, depending on what they do best:
Code:// Bla bla bla (only need one line)- SirCrono6Code:/*bla *bla bla *bla bla *bla (need several lines) */
From C to shining C++!
Great graphics, sounds, algorithms, AI, pathfinding, visual effects, cutscenes, etc., etc. do NOT make a good game.
- Bubba
IDE and Compiler - Code::Blocks with MinGW
Operating System - Windows XP Professional x64 Edition
it depends... look at this piece of code:I do the C-style comments (/**/) for header information and multi line things... and sometimes in classes to sepreate functions. I use C++ comments (//) for single line things... sometimes I use a mix (not really) like this:Code:... if(p2.hp>0) //if player two survives turn=2; //time for player two to attack else //if player two dies turn=0; //no more attacking } if(turn==2) //player two's turn { atkdam=p2.atk*static_cast<double>((1+rand()%100)/100.0); atkdam+=p2.spd*static_cast<double>((1+rand()%25)/100.0); defdam=p1.def*static_cast<double>((1+rand()%75)/100.0); defdam=p1.spd*static_cast<double>((1+rand()%25)/100.0); /* How things are watered down: atk==100% def==50% spd==12% */ ...Code://*********************************************// // Title Of Section // //*********************************************//
Last edited by major_small; 01-18-2004 at 08:36 PM.
Join is in our Unofficial Cprog IRC channel
Server: irc.phoenixradio.org
Channel: #Tech
Team Cprog Folding@Home: Team #43476
Download it Here
Detailed Stats Here
More Detailed Stats
52 Members so far, are YOU a member?
Current team score: 1223226 (ranked 374 of 45152)
The CBoard team is doing better than 99.16% of the other teams
Top 5 Members: Xterria(518175), pianorain(118517), Bennet(64957), JaWiB(55610), alphaoide(44374)
Last Updated on: Wed, 30 Aug, 2006 @ 2:30 PM EDT
I prefer // comments. I rarely use the C-style ones. As far as when I put them in, anything related to the implementation of a function, etc. I write at the same time I am writing the code. Other comments (header comments, function descriptions, etc.) I write later.
If I use C-style at all, I use it in the javadoc fashion, e.g.
Code:/** This function does nothing. * @param x a useless parameter * @return 5 */ int donothing(int x) { return 5; }
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
I prefer frame-like comments for function headers n such. They are visible enough to easily find the functions when searching the file but still doesn't make it messy like * do (IMO). I believe this is LISP style.
For normal comments a simple // does the job.Code://+--------------------------- //| Yada yada //+--------------------------- int f() { return 0; }
Code:// Yada yada int x = f();
MagosX.com
Give a man a fish and you feed him for a day.
Teach a man to fish and you feed him for a lifetime.
I only use C-style comments when I'm debugging and I want to "comment-out" a chunk of code to narrow-down the problem.
also *sometimes* i use the c-style comments for documentation at the top of the program for my teacher (he's strict about having a plan )
"uh uh uh, you didn't say the magic word"
-Jurassic Park
I don't think it really matters, but remember that there are compilers out there that do not allow nested /* */ comments. If you run across this when you are porting an application to a new compiler you will have to use #if 0 to comment out chunks of code that have been commented with /* */ comments. You probably won't run across this unless you are compiling with a very specific compiler for an embedded target.