English 中文(简体)
Do I need to javadoc every single method or just the main method in java? [closed]
原标题:
  • 时间:2009-12-02 18:23:01
  •  标签:
  • java
  • javadoc

Java example method:

//Stores the user input into an integer variable called  choice 
int choice = keyboard.nextInt();

Do I need to write javadoc for a simple method like this or should I only document the main method of any program, if so then what sort of things should I write for the main method?

Thanks,

Chris.

问题回答

This was explained in your other thread: What should I write in my javadoc class and method comments?

What you have posted is not a method either. You do not need to comment every line of code, even for an assignment. If you have something obvious such as:

i++;

You do not need to comment it with "increments i by one."

Again, code comments (including JavaDoc) do not affect the execution of the code.

Need? That depends on what you mean by "need".

I think there s a few confusions in your question. One of them is what constitutes a method. You seem to be asking about comments in general. Javadocs are a specific form of comment (with a particular syntax). Also, a quibble: your example above isn t a method. It s a single line of code.

But addressing just that, I wouldn t use that comment. Clearly you re setting a variable called "choice". The only thing interesting there is what nextInt does, but anyone curious should be able to hover over the nextInt() method and see its javadocs.

First off, that example is not javadoc, just a code comment

Here is a tutorial on javadoc How to write javadoc

And you should only javadoc public facing methods





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签