Jump to content

Comments Style


Maki

Recommended Posts


  • Group:  Members
  • Topic Count:  146
  • Topics Per Day:  0.03
  • Content Count:  1195
  • Reputation:   467
  • Joined:  11/15/11
  • Last Seen:  

Ind:

As brought up by Error404 and GodLesZ commenting is a very welcome habit which helps not only other developers to understand your code faster but to users trying to modify the source in some way.

I've given it a try on the r55 and would like to know your opinion on it, hows done, layout (got a better idea for a pattern? mines not good), etc. Let me know what you think.

Thank you for your time.

GodLesZ:

What about a whole doc on the source? this would help a lot new guys, like SRC funcs and whatnot.

Indeed, but this will be a lot of work and a over-time milestone.

We should try to document any point of code if we visit him and have some time.

This way i document old projects of mine which arent documented well.

Every time i visit the code to look for something or extend it, i add documentation to every spot i see. This dosnt take too much time @ once and documents the code over the time.

If we documented the most of the code we should setup a DoxyGen or another script to create a html or pdf document.

I know, double post, but its a totally new question.

We should decide a comment-style.

I like to use the XML-style, covered from my C# coding:

/// <summary>

/// Some description

/// </summary>

/// <param name="id">Session id</param>

/// <return>1 on any error</return>

int clif_some_function(int id) {

The other often used style is javadoc, commonly used in java, php ect.

(Note: Style may varry from user to user)

/**

* Some description

*

* @param id Session id

*

* @return int 1 on any error

*/

int clif_some_function(int id) {

It is most often a user question, but i hate it to see 5 or more comment styles in the eAthena code even in one file..

So i think someone has to clean it up and standardize them.

Once we had commented all in a regular same way, we may use tools to generate a whole server documentation (doxygen i.e.), like mentioned in the post above.

I will try to test some comment add-ins for Visual Studio to refactor comments. Also some simple scripts for parsing existing comments and standardize them wont be that hard.

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  25
  • Topics Per Day:  0.01
  • Content Count:  257
  • Reputation:   253
  • Joined:  11/29/11
  • Last Seen:  

I personally like the XML comment style.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  117
  • Reputation:   167
  • Joined:  11/10/11
  • Last Seen:  

The XML style isn't fully supported by C++ clients though. I know that javadocs; are supported, usually in either the format:

/**
* some line of description here outlining the process.
* @param something a description of something
* @return bool whether or not it is true!
*/

Or the same but:

/**
* some line of description here outlining the process.
* param something a description of something
* return bool whether or not it is true!
*/

I think having XML all over the place might look a little crowded? Just a thought :)

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  169
  • Topics Per Day:  0.04
  • Content Count:  1260
  • Reputation:   750
  • Joined:  11/19/11
  • Last Seen:  

I personally agree with Epoque, I think it'd crowd the comments unnecessarily (XML). I'd rather go with javadoc

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

Using block comments on single lines underneath make it look overly complex...

I would suggest the full block @ the top (what it does)

then a mini block above each line of code

/*
* This is my super script from source and stuff kk?
*/
if (sd->rawr) {

 /* checks to see if he's online */
if (a ==  { }
}
/* end */

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

I'm fine with either block comment style. Doxygen can probably parse both =]

@Z3R0: but not comments for every single line, right?

Only for really complex lines that, at a glance, it's not immediately obvious what the code is doing.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  186
  • Reputation:   51
  • Joined:  11/14/11
  • Last Seen:  

I'd like to suggest the style of my company I'm working on.

We use it for PHP, Python, Perl, C, C++ and even Assembler.

/**
* Description here,
* Even multilined.
* - 1 line space before params or return statements
* - 1 line space between params and return statements
*
* @param<TAB><name of param><TAB><Parameter description>
*
* @return<TAB><type of return><TAB><Return description>
*/

This is our style of comments and is used above every function/method/prodcedure and is supported natively from doxygen i.e.

I would love to see somedays every comment in that way <3

Also, if a comment takes 2 or more lines, we use multiline comment blocks. If not, single line comments of course.

Suggestions?

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  5
  • Reputation:   0
  • Joined:  12/17/11
  • Last Seen:  

Imo it would be better to use doxygen-styled comments, the doxygen itself generates an online documentation that's very good to search for functions. http://www.stack.nl/~dimitri/doxygen/

But after all it's all up to the devs to choose whether to use it or not...

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

Yes we plan to use doxygen.

Here's the link to the old eAthena Doxygen: http://eathena.sf.net/doxygen/

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

I'd like to suggest the style of my company I'm working on.

We use it for PHP, Python, Perl, C, C++ and even Assembler.

/**
* Description here,
* Even multilined.
* - 1 line space before params or return statements
* - 1 line space between params and return statements
*
* @param<TAB><name of param><TAB><Parameter description>
*
* @return<TAB><type of return><TAB><Return description>
*/

This is our style of comments and is used above every function/method/prodcedure and is supported natively from doxygen i.e.

I would love to see somedays every comment in that way <3

Also, if a comment takes 2 or more lines, we use multiline comment blocks. If not, single line comments of course.

Suggestions?

Totally supporting that one. Nice and clean.

Question to the Style of GodLesZ:

When the i.e. the return value is returning error code like: 0 - no error, 1 - error and so on. How to you write that into description.

Like:

* @return<TAB>int<TAB>error code for calling function
* 0 - no error
* 1 - error

or else?

Edited by Jonne
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...