Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 67585
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:16:59+00:00 2026-05-10T19:16:59+00:00

Should I be writing Doc Comments for all of my java methods?

  • 0

Should I be writing Doc Comments for all of my java methods?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-10T19:16:59+00:00Added an answer on May 10, 2026 at 7:16 pm

    @Claudiu

    When I write code that others will use – Yes. Every method that somebody else can use (any public method) should have a javadoc at least stating its obvious purpose.

    @Daniel Spiewak

    I thoroughly document every public method in every API class. Classes which have public members but which are not intended for external consumption are prominently marked in the class javadoc. I also document every protected method in every API class, though to a lesser extent. This goes on the idea that any developer who is extending an API class will already have a fair concept of what’s going on.

    Finally, I will occasionally document private and package private methods for my own benefit. Any method or field that I think needs some explanation in its usage will receive documentation, regardless of its visibility.

    @Paul de Vrieze

    For things, like trivial getters and setters, share the comment between then and describe the purpose of the property, not of the getter/setter

    /**   * Get the current value of the foo property.  * The foo property controls the initial guess used by the bla algorithm in  * {@link #bla}  * @return The initial guess used by {@link #bla}  */ int getFoo() {   return foo; } 

    And yes, this is more work.

    @VonC

    When you break a huge complex method (because of high cyclomatic complexity reason) into:

    • one public method calling
    • several private methods which represent internal steps of the public one

    , it is very useful to javadoc the private methods as well, even though that documentation will not be visible in the javadoc API files.
    Still, it allows you to remember more easily the precise nature of the different steps of your complex algorithm.

    And remember: limit values or boundary conditions should be part of your javadoc as well.

    Plus, javadoc is way better than simple "//comment":

    • It is recognized by IDE and used to display a pop-up when you move your cursor on top of one of your – javadoc-ed – function. For instance, a constant – that is private static final variable -, should have a javadoc, especially when its value is not trivial. Case in point: regexp (its javadoc should includes the regexp in its non-escaped form, what is purpose is and a literal example matched by the regexp)
    • It can be parsed by external tools (like xdoclet)

    @Domci

    For me, if somebody will see it or not doesn’t matter – it’s not likely I’ll know what some obscure piece of code I wrote does after a couple of months. […]
    In short, comment logic, not syntax, and do it only once, on a proper place.

    @Miguel Ping

    In order to comment something, you have to understand it first. When you trying to comment a function, you are actually thinking of what the method/function/class does, and this makes you be more specific and clear in your javadoc, which in turn makes you write more clear and concise code, which is good.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 92k
  • Answers 92k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It should work on every (decent) browser including IE 7.… May 11, 2026 at 6:28 pm
  • Editorial Team
    Editorial Team added an answer In both cases, you're not handling any disposal issues of… May 11, 2026 at 6:28 pm
  • Editorial Team
    Editorial Team added an answer A redirect, as others suggest, does have some advantage, but… May 11, 2026 at 6:28 pm

Related Questions

I am in the process of writing an application which, among other functionality, generates
I am writing my first taglib as part of a plugin and I would
I'm writing a new Windows Forms 2.0 application. This application is going to have
I'm writing some documentation in Markdown, and creating a separate file for each section

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.