0

How should I comment a method?

What are the best practices on commenting code?

Example:

/* Checks if a color is allowed in a given point
* of the bitmapdata of the current floor
* @param value - color to be checked
* @return boolean - if color is allowed returns true, else, return false
*/
private function isAllowed(value:uint):Boolean {
 //code...
}

Is that the best way to comment a method?

I ́ve heard there ́s the use of the tag @see. What should be on this tag? I wonder if it could be something that has a relation to the method, is that right?

Thanks.

asked Apr 14, 2012 at 19:05
1

2 Answers 2

0

The best way to comment a method is to follow the existing standard in the project you're working in.

In new projects where you have control, the syntax you've got above is fine.

For that particular method, renaming it to isColorAllowed() would obviate the need for any function header at all, presuming that there is no existing standard about such things.

answered Apr 14, 2012 at 21:06
0

Good code should be descriptive enough that it shouldn't need comments. For example the method should do one thing only and have a name that describes that purpose.

Any parameters passed in should also be properly named so that @param type comments don't need to be used.

Perfect code would be comment-free and would read almost like English.

answered Dec 22, 2014 at 10:08

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.