Agreed. I comment my code a lot for uni as we tend to work in groups. Also I have a head like a sieve so i tend to forget what i was doing in watever source file i'm looking in, especially if i havent worked on the project in a while. Sure, i can figure out what's happening but whats the point when i can just add a few comment lines and save that time.avansc wrote:I dont comment shit, its really bad.
Here are a few reasons i suggest commenting a lot.
Getting into the habit even if you dont need it at the time is a good idea, for the fact that alot of large project require it, especially if you work for a decent place.
Keeping source well commented to a certain style makes producing documentation easy, doxygen, javadoc and all those kinda things.
People forget shit, i dont care how smart you think you are, you will oneday look at a simple loop or what not and go, "WTF am i doing here". Im not saying you cant figure it out, but comments make it alot easier.
and lastly, if you are not the only person that will work with the code. or even if someone just calls your code, they can reference the documentation you specifically wrote.
How do YOU comment a source file?
Moderator: Coders of Rage
- MrDeathNote
- ES Beta Backer
- Posts: 594
- Joined: Sun Oct 11, 2009 9:57 am
- Current Project: cocos2d-x project
- Favorite Gaming Platforms: SNES, Sega Megadrive, XBox 360
- Programming Language of Choice: C/++
- Location: Belfast, Ireland
- Contact:
Re: How do YOU comment a source file?
http://www.youtube.com/user/MrDeathNote1988
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
"C makes it easy to shoot yourself in the foot. C++ makes it
harder, but when you do, it blows away your whole leg." - Bjarne Stroustrup
Re: How do YOU comment a source file?
Well at the top of each file I usually do something like:
Then I usually just have some single line comments throughout, where I think I need to explain something.
Code: Select all
Author:
Description:
- Milch
- Chaos Rift Junior
- Posts: 241
- Joined: Sat Jul 11, 2009 5:55 am
- Programming Language of Choice: C++
- Location: Austria, Vienna
Re: How do YOU comment a source file?
I'm working with CodeBlocks and a DoxyGen plugin, so I have comments like this in each header for the different functions:
This is pretty cool for group projects, because they only have to hit a button and they have a supersexy documentation in .html format, or they just switch to the header and read it themselves.
In my the implementation of the function there are just normal comments and ToDo's for the CodeBlocks ToDo Plugin, sometimes a '#warning' so nothing special.
Code: Select all
////////////////////////////////////////////////////////////
///A supercool function
/// \param data - takes a pointer to something
/// \return a pointer to something different
////////////////////////////////////////////////////////////
Bla* Function( char* data );
In my the implementation of the function there are just normal comments and ToDo's for the CodeBlocks ToDo Plugin, sometimes a '#warning' so nothing special.
Follow me on twitter!
- GroundUpEngine
- Chaos Rift Devotee
- Posts: 835
- Joined: Sun Nov 08, 2009 2:01 pm
- Current Project: mixture
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Location: UK
Re: How do YOU comment a source file?
Agreed, I only do that type of comment on open source or group project, or whateverGyroVorbis wrote:I would only ever add that stuff to a finished open source project just so people can't steal my work...
Anyways this is what I tend to do ->
Code: Select all
/********************************************************
* "Filename"
* "Project Name"
*
* Created by "Creators Name"
* Last Updated on "Date" [or] Created on "Date"
* Copyright "Year Project Begun" by "Creators Name". All rights reserved. [or] "License Info"
*
*********************************************************/
- jasongosen
- Chaos Rift Newbie
- Posts: 7
- Joined: Fri Jun 04, 2010 1:14 pm
Re: How do YOU comment a source file?
I'm using Java and I love comments! The nice Javadoc generator is similar to doxygen in that it looks for special keywords to add descriptions to classes, fields, and methods in the documentation. Plus you never know, down the road you could forget what your mindset was at the time of writing a block of code. Maybe you forgot the precondition for a method or something.
- SD021
- Chaos Rift Newbie
- Posts: 31
- Joined: Wed Oct 29, 2008 1:32 pm
- Current Project: Yes :P
- Favorite Gaming Platforms: PC
- Programming Language of Choice: C++
- Location: Ireland
Re: How do YOU comment a source file?
I'm a firm believer in 'good code comments itself'. I write all my code asking myself would someone else be able to read it without comments.
I think uncommented code is miles better than over commented code tbh
That's just me though
I think uncommented code is miles better than over commented code tbh
That's just me though
Check out my channel: http://www.youtube.com/user/QuestForMario
-
- Chaos Rift Newbie
- Posts: 3
- Joined: Mon Jun 21, 2010 1:09 pm
Re: How do YOU comment a source file?
It is depend on the programming language. Which language do you use?. Because different programming language has different style of comments so there is no problem regarding any files,syntax, statements or your own code. It is just comment weather it is source file or etc.
-
- Chaos Rift Junior
- Posts: 209
- Joined: Thu Feb 12, 2009 8:46 pm
Re: How do YOU comment a source file?
I code how Sun... *ahem* ORACLE tells me to.
Click here to see the hidden message (It might contain spoilers)
- Ginto8
- ES Beta Backer
- Posts: 1064
- Joined: Tue Jan 06, 2009 4:12 pm
- Programming Language of Choice: C/C++, Java
Re: How do YOU comment a source file?
god DAMN that's too much commentation. Anyone who needs to comment like that must have absolutely horrid naming conventionswearymemory wrote:I code how Sun... *ahem* ORACLE tells me to.
Click here to see the hidden message (It might contain spoilers)
Quit procrastinating and make something awesome.
Ducky wrote:Give a man some wood, he'll be warm for the night. Put him on fire and he'll be warm for the rest of his life.
Re: How do YOU comment a source file?
thats for javadoc, its not too much.Ginto8 wrote:god DAMN that's too much commentation. Anyone who needs to comment like that must have absolutely horrid naming conventionswearymemory wrote:I code how Sun... *ahem* ORACLE tells me to.
Click here to see the hidden message (It might contain spoilers)
how else do you think those lovely html documents get made?
Some person, "I have a black belt in karate"
Dad, "Yea well I have a fan belt in street fighting"
Dad, "Yea well I have a fan belt in street fighting"
- ismetteren
- Chaos Rift Junior
- Posts: 276
- Joined: Mon Jul 21, 2008 4:13 pm
Re: How do YOU comment a source file?
Thats javadoc... its meant to be read without reading any code but the method definition.... You should only comment like that if you plan to make documentation using javadoc.Ginto8 wrote:god DAMN that's too much commentation. Anyone who needs to comment like that must have absolutely horrid naming conventionswearymemory wrote:I code how Sun... *ahem* ORACLE tells me to.
Click here to see the hidden message (It might contain spoilers)