Coding Comment Styles C++, C, Java

trippy1976

Member
Jan 6, 2002
148
0
76
Wondering from the programmers out there - what's your preferred commenting style? I like to call out portions of code using comments and have been using something along the lines of:

//----------------------------
// A comment.
// Line two
//----------------------------

I don't particularly care for this as it's hard to add text to line one and get it to stay in bounds of the dashes and look 'neat'. I tried

/*--------------------*\
A comment
\*--------------------*/

As an alternative, but I still don't like it. Thought others might have opinions.
 

safoo

Senior member
Sep 30, 2001
330
0
0
//i always comment like this
//im just used to it since high school. i never cared for using '/*'
 

MustPost

Golden Member
May 30, 2001
1,923
0
0
// use this style

/*use this only when temporarily removing something from a "for" statesment*/
 

Kilrsat

Golden Member
Jul 16, 2001
1,072
0
0
//This is an example of my typical java comment for the sake of clarifying a line

/**
* Sometimes it looks like this, but
* This is mainly reserved for class/function
* headings
**/

#This is an example of my typical SAL comment
#Since I end up putting one of these on virtually every line
#Archaic languages are no fun, really
 

Descartes

Lifer
Oct 10, 1999
13,968
2
0
Evil commenting styles:

/************************
* *
* EVIL! *
* *
* *
************************/

and...

int var; // trying
int var2; // to
int var3; // keep
int var4; // these lined up makes this evil too!

I actually don't mind...

/*
** This for method comments
**
**
**/

Comments in C# for XML documentation...

/// <summary>
/// Great way to document
/// </summary>

That's just a sample, there are a slew of available tags one can use in their comments for XML documentation in C#.

And for Java to generate documentation from Javadoc, it looks pretty familiar.

/**
* Some description.
* @param (someparam) somedescription
* @return (description of return value
*/

For C or C++ I have my own style format that I use to extract pertinent information from the source files. Just don't get too carried away with your commenting style. Succinctness is the key here, not verboseness.

[edit]It hosed my formatting, I forgot, sorry.[/edit]
 

Alex

Diamond Member
Oct 26, 1999
6,995
0
0
i only know VB :(

'so therefore
'this is the only
'way to comment
'damn single speachmark thingies! :D
 

Pakaderm

Senior member
Mar 8, 2001
519
0
0
I don't use comments. The code was hard to write, it should be hard to read too.

-Pak
 

yoda291

Diamond Member
Aug 11, 2001
5,079
0
0


<< I don't use comments. The code was hard to write, it should be hard to read too.

-Pak
>>



ur jokin right?

I use // and only // for comments. That way, I can use /* for debugging
 

calpha

Golden Member
Mar 7, 2001
1,287
0
0
I only comment on the comments that are outdated since I've been a fireman my whole life.
 

Noirish

Diamond Member
May 2, 2000
3,959
0
0
i try to comment, but i usually forget.
when it's crunch time and i have to deliver my stuff, i usually don't comment.

however

/**
* this is good
*/

/*
this is good for commenting out useless codes assuming your ide auto indent for you
*/

// this is for one liner
 

spamsk8r

Golden Member
Jul 11, 2001
1,787
0
76


<< I don't use comments. The code was hard to write, it should be hard to read too.

-Pak
>>



Darn tootin, I don't want other people messing with my stuff anyway :)