473,394 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

source code commenting

Hello

I've been programming for a number of years, however my commenting style is
always different.
Sometimes I use something like:

/************************
* method ....
* comments...
*************************/

Sometimes I use:
//
// this function is for this and that...
// ...

etc...then when it comes to write documents about my code, I'ld have to
rewrite lots of explanation about the code in another document.

I don't know what style to adopt and what tools can later parse my code and
generate documentation out of my specially formatted comments. (for example
Javadoc, can parse source-code and generate comments)

What do you use?
What do you suggest?

Regards,
Elias
Feb 2 '06 #1
8 1838
lallous wrote:
Hello

I've been programming for a number of years, however my commenting style
is always different.
Sometimes I use something like:

/************************
* method ....
* comments...
*************************/

Sometimes I use:
//
// this function is for this and that...
// ...

etc...then when it comes to write documents about my code, I'ld have to
rewrite lots of explanation about the code in another document.

I don't know what style to adopt and what tools can later parse my code
and generate documentation out of my specially formatted comments. (for
example Javadoc, can parse source-code and generate comments)
Yes, you should format those comments in such a way that they can be used by
a documentation too.

What do you use?
doxygen
What do you suggest?


doxygen

See http://www.doxygen.org

Feb 2 '06 #2
Rolf Magnus wrote:
lallous wrote:
Hello

I've been programming for a number of years, however my commenting style
is always different.

<snip>

I don't know what style to adopt and what tools can later parse my code
and generate documentation out of my specially formatted comments. (for
example Javadoc, can parse source-code and generate comments)


Yes, you should format those comments in such a way that they can be used by
a documentation too.
What do you use?


doxygen
What do you suggest?


doxygen

See http://www.doxygen.org


ditto (with the Javadoc style comments, 'cos I learnt with Java)

Ben Pope
--
I'm not just a number. To many, I'm known as a string...
Feb 2 '06 #3
lallous wrote:
Hello

I've been programming for a number of years, however my commenting style is
always different.
Sometimes I use something like:

/************************
* method ....
* comments...
*************************/

Sometimes I use:
//
// this function is for this and that...
// ...

etc...then when it comes to write documents about my code, I'ld have to
rewrite lots of explanation about the code in another document.

I don't know what style to adopt and what tools can later parse my code and
generate documentation out of my specially formatted comments. (for example
Javadoc, can parse source-code and generate comments)

What do you use?
What do you suggest?

Regards,
Elias


I use doxygen to generate documentation and after changing style many
times I have settled on // C++ style commenting. This way I can use C
style comments to disable entire sections of code during debugging and
not have to worry about whether the compiler will have a fit because of
nested comments.

--
Ben Radford
"Why is it drug addicts and computer aficionados are both called users?"
Feb 2 '06 #4

Ben Radford wrote:
I use doxygen to generate documentation and after changing style many
times I have settled on // C++ style commenting. This way I can use C
style comments to disable entire sections of code during debugging and
not have to worry about whether the compiler will have a fit because of
nested comments.


I just use the preprocessor when I am worried about that. Of course
I'm not the only one developing and I'm comming in on a 10 year old or
more product....I don't get to establish style guidelines and stick to
them...they are given to me and with the age and the amount of hands
that have been in the pot wel....not everyone follows style guidelines.

#if 0

CODE

#endif

will block out anything no matter what comments, etc, are in CODE. The
only time you run into trouble is if you split another preprocessor
segment and it splits your new one as well.

Feb 2 '06 #5
ro**********@gmail.com wrote:
#if 0

CODE

#endif


I hadn't thought of that but it works just as well as my method. I use
mine because my editor will highlight the comments in grey and italics
making it easy to see what has been disabled. Just a minor point though.

--
Ben Radford
"Why is it drug addicts and computer aficionados are both called users?"
Feb 2 '06 #6
Ben Radford <be**************@new.ox.ac.uk> wrote:
ro**********@gmail.com wrote:
#if 0

CODE

#endif


I hadn't thought of that but it works just as well as my method. I use
mine because my editor will highlight the comments in grey and italics
making it easy to see what has been disabled. Just a minor point though.


My editor will also highlight the #if 0 ... #endif block the same as
comments. However, I don't wish to start an editor war so that's all
I'll say about this.

--
Marcus Kwok
Feb 2 '06 #7
Marcus Kwok wrote:
Ben Radford <be**************@new.ox.ac.uk> wrote:
ro**********@gmail.com wrote:
#if 0

CODE

#endif


I hadn't thought of that but it works just as well as my method. I use
mine because my editor will highlight the comments in grey and italics
making it easy to see what has been disabled. Just a minor point though.

My editor will also highlight the #if 0 ... #endif block the same as
comments. However, I don't wish to start an editor war so that's all
I'll say about this.


Hehe =). I don't view my editor religiously so there's no danger of that
happening; especially as I've just discovered it *does* infact highlight
#if 0 ... #endif blocks. I should probably have checked this before I
posted it as the reason for my preference.

--
Ben Radford
"Why is it drug addicts and computer aficionados are both called users?"
Feb 2 '06 #8

"lallous" <la*****@lgwm.org> wrote in message
news:44************@individual.net...
Hello

I've been programming for a number of years, however my commenting style
is always different.
Sometimes I use something like:

/************************
* method ....
* comments...
*************************/

Sometimes I use:
//
// this function is for this and that...
// ...

etc...then when it comes to write documents about my code, I'ld have to
rewrite lots of explanation about the code in another document.

I don't know what style to adopt and what tools can later parse my code
and generate documentation out of my specially formatted comments. (for
example Javadoc, can parse source-code and generate comments)

What do you use?
What do you suggest?

Regards,
Elias


Personally, I only use // for comments. I use /* */ to comment out blocks
of code only.

Too much of a pain to search for /* to find commented out code and running
into comments.

Although I will use // to comment out a single line of code.
Feb 3 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: Profetas | last post by:
Hi, I know that this is off topic. but I didn't know where to post. Do you comment your source code while coding or after coding. for example: you write a procedure and after it is...
18
by: Marian F. | last post by:
The 12 years old genius function to count english words in a sentence: ' This is my function to count english words in your string ' s is the string with your words to be counted ' Returns an...
8
by: Bob | last post by:
I need to create a Regex to extract all strings (including quotations) from a C# or C++ source file. After being unsuccessful myself, I found this sample on the internet: ...
10
by: Diomidis Spinellis | last post by:
A quick note to inform my fellow C programmers that my new book "Code Quality: The Open Source Perspective" (Addison-Wesley, 2006) has just been published. All 623 examples I use in the book are...
2
by: RYoung | last post by:
Can someone point me to a reference concerning source code commenting with VB 2005, ala C# commenting? I googled and found alot of links to add-ins and commercial products, but I can't find any...
31
by: smachin1000 | last post by:
Hi All, Does anyone know of a tool that can automatically analyze C source to remove unused #includes? Thanks, Sean
3
by: Martin P. Hellwig | last post by:
Hi all, I've been toying with python for about two years now. Not every day, just when I encounter something in my job (sysadmin) repetitively dull. The amazing thing is that like any other...
6
by: dimitris.papastamos | last post by:
Hello everyone, I've been working on a simple editor myself and I seem to be having some problems with ncurses or so. I have been debugging this program quite a lot trying to detect where the bug...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.