Search code examples
javajavadoccomments

Should I comment when calling a method?


I would like to know if I should comment before calling a method. For example:

//calling method
MethodCall();

or is it good enough with the javadoc commenting on the method header for example:

/**
some method 
*/
public static void() {
    Statements;
}

Which one should I use or should I use both?


Solution

  • One of many reason of comment is to help otherss (and you) to understand what and mainly why you do what you do, but there is no need to write comment such as this:

    // Loop through all bananas in the bunch
    foreach(banana b in bunch) {
        monkey.eat(b);  //make the monkey eat one banana
    }