Original Post
I was just wondering what everyones take is on the most understandable commenting methods for functions and classes? I'm going to be adopting a style and have no idea which one to use.
Quote:Agreed, not what you're doing, but why.
Original post by ajas95
Writing comments is the easy part. The hard part is keeping them accurate/relevant as code is changed and bugs fixed and introduced.
Quote:
Original post by RobTheBloke
most important rule: comment what the code does, not how it does it....
/*--------------------------------------Node-------------------------------------------*\ ||| Created 6/1/2005 Last Modified 3/8/2005\*--------------------------------------Node-------------------------------------------*/ //Constructors inline Node(); explicit inline Node(const String& aName); Node(Stream& stream, const ChunkHeader& header, const Resource::Group& resources); virtual ~Node();/***********************************Constructors****************************************/ //---------------------------------------------------------------------------------------//---------------------------------------------------------------------------------------// Sets the name the node to the specified string.//---------------------------------------------------------------------------------------void Node::SetName(const String& aName){ name = aName;}
Quote:
Original post by RobTheBloke
most important rule: comment what the code does, not how it does it....
good comment :
// sum all ages
for(unsigned i=0;i!=nm;++i)
total += values;
bad comment (tells me nothing that i couldn't determine from the code) :
// for each value, add to total
for(unsigned i=0;i!=nm;++i)
total += values;
as mentioned, commenting headers using javadoc, doc++ or doxygen comments is a damn good idea. I use doxygen personally....
int SumAges(int Ages[], int NumberOfAges){int SumOfAges = 0;for(unsigned int AgeIterator =0; AgeIterator < NumberOfAges; ++AgeIterator ) SumOfAges += Ages[AgeIterator ];return SumOfAges;}void function(){....int SumOfAllAges = SumAges(Ages, NumberOfAges);}Quote:
Original post by Jingo void function()
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more