Where to place comments and javadoc ? Model or Controller?

Asked

Viewed 168 times

1

I’m doing an MVC program, but it’s time to describe in a javadoc what each window does, I was in doubt between putting these comments in the forms (Model), or us controllers of the respective windows. Which would be the most correct ? Because the form is the essence of the window, and the controller is who does most things ... Help me !

2 answers

1

javadoc is not the most suitable tool to describe how to use the graphical interface application, if that’s what you’re trying to do. It serves for you to describe how to use the classes (and methods consequently) of your project.

In this case, if what you want to do is actually document the classes, you should do this in both the model and the controller.

  • What would be the best way to describe the function of a given class and/or method ? Even the "normal" comments themselves ?

  • 1

    @Danielsantos no, regarding classes and/or methods (which will be used by other developers, or even you in the future) is that you should use javadoc. What I mentioned was that if the idea was to document the use of the graphical interface by the users there yes javadoc would not be the most appropriate.

1


We should give at least a brief description of both, so that the programmer who will catch them does not even have the possibility of not understanding what it is.

/**
 * Modelo para criação e validação do Código de Barras da Caixa
 * 
 * @author João Victor B. Magalhães 
 * @since   0.1
 * @version 0.1
 * 
 */
public class CodigoDeBarrasCaixa implements CodigoDeBarrasBoleto {
    private String digitos;
    private BoletoBancario boleto;

    private static final int TIPO_DE_COBRANCA = 2;
    private static final int ID_EMISSOR_BOLETO = 4;
    private static final int TIPO_MOEDA = 9;
}

I don’t see the need to document the Getters and Setters, but if you have a more complex method or an attribute that is difficult to understand, you should document it as well. In the controller the same thing, give a description of what he does and if he has any method out of the "common" document it. If you’re already a program that’s distributed on a team put @Ince always so the team knows when you’ve added the method and @version as well.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.