Skip to content

Decide on javadoc guidelines #891

Closed
Closed

Description

@stefanholder

Currently, a number of methods is not or only poorly documented with javadoc, which makes it hard for others to contribute. This also applies to the map-matching repository.

I think what we need are is a javadoc convention (see also #774) that applies to all new contributions. I would suggest to adopt the javadoc rules from the Google Java Style Guide, which describe where javadoc is required.

In addition to where javadoc is required, we also need some agreement on how to write good javadoc comments.

In #774, @karussell commented:

Also what to comment and what not is important and this is a good read: https://visualstudiomagazine.com/articles/2013/06/01/roc-rocks.aspx
It's important to communicate what the code should be doing. Comments should explain the "why" of the code and stop there.
What comments should never, ever do is explain how the code does its job.

Activity

  1. boldtrn commented on Dec 1, 2016

    @boldtrn
    Member

    Yes the code is not commented a lot. I think we should aim for speaking names, short (if possible ;)) methods that can be understood easily. We should break the methods into smaller methods where possible and assign speaking names to the methods, so it becomes clear what happens. This is basically the approach presented in Clean Code (by Robert Martin). I think most method comments are unnecessary, however some methods are rather complex, these are typically documented already.

    Javadoc becomes outdated very fast. Usually with the next refactoring one has to fix the Javadoc anyway.

    In #774, @karussell commented:
    +1

  2. stefanholder commented on Dec 1, 2016

    @stefanholder
    ContributorAuthor

    It's important to communicate what the code should be doing.

    I agree. An additional criterion for good javadoc comments is for me that users of the API should understand from javadoc alone how to use the API. Often it is not sufficient to just roughly describe what a method does but to be precise about the preconditions, postconditions and side effects of a method. An example for good javadoc is the java.util package. e.g. ArrayList. It does fully explain how to use the API without giving implementation details.

    IMHO, the best mindset for writing good javadoc is Design by Contract.

    Javadoc becomes outdated very fast.

    I would require that javadocs are updated with every pull request by the pull request author. This way javadoc never becomes outdated.

  3. karussell commented on Dec 1, 2016

    @karussell
    Member

    be precise about the preconditions, postconditions and side effects of a method

    yes, like information about thread-safety and if stateless.

    Javadoc becomes outdated very fast.

    I would require that javadocs are updated with every pull request by the pull request author. This way javadoc never becomes outdated.

    Yes but still it can happen that when doing some 'global' refactoring a local javadoc could get meaningless or wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions