# JavaDocs

When writing good software, it’s essential to write good documentation as well. For that reason, there should be a collection of guidelines and best practices agreed upon on the company level for writing good and concise code documentation based upon reliable sources. In short, JavaDoc is a document generator tool in Java programming language for generating documentation in HTML format. Every JavaDoc comment must include the following:

```
/**
Comment
/*
```

{% hint style="info" %}
All of the comments are removed at compile time so it doesn’t affect the performance of the execution.
{% endhint %}

## Good practices <a href="#javadocs-goodpractices" id="javadocs-goodpractices"></a>

JavaDoc should be defined at the company or team level to ensure consistency and coherence in documentation practices. Here are some of the good practices:

<table data-card-size="large" data-view="cards"><thead><tr><th></th><th></th></tr></thead><tbody><tr><td><strong>Use standard JavDoc tags</strong></td><td>Include standard block and inline tags like: <code>@param</code>, <code>@return</code>, <code>@throws</code>, <code>@see</code>, <code>@since</code> , <code>{@link}</code> and<code>@deprecated</code> to describe parameters, return values, exceptions, and deprecated methods respectively.</td></tr><tr><td><strong>Be descriptive, clear and concise</strong></td><td>Write clear and concise descriptions for methods, classes, fields, and parameters. Explain what they do and their significance.</td></tr><tr><td><strong>Adhere to naming conventions</strong></td><td>By using meaningful names for methods, classes, and variables, ensuring that their purpose is clear from the name itself, we can avoid writing redundant comments that clutter the code.</td></tr><tr><td><strong>Use HTML markup sparingly</strong></td><td>Use HTML markup (such as <code>&#x3C;code></code>, <code>&#x3C;ul></code>, <code>&#x3C;li></code>, etc.) when necessary to format text for better readability. But keep it minimal and use it only when needed.</td></tr><tr><td><strong>Include example usage</strong></td><td>Add code snippets or examples to demonstrate how to use a method or class.</td></tr><tr><td><strong>Update JavaDocs regularly</strong></td><td>As you change code, update the JavaDocs regularly. Outdated comments can lead to confusion.</td></tr><tr><td><strong>Document edge cases and specifics</strong></td><td>Mention any edge cases, restrictions, or constraints that might affect the behaviour of the method or class.</td></tr><tr><td><strong>Document thread safety and performance</strong></td><td>Describe if methods or classes are thread-safe and mention any performance considerations or complexities.</td></tr><tr><td><strong>Use inline comments when necessary</strong></td><td>For complex logic or sections that might not be clear from the JavaDoc alone, use inline comments within the code to provide additional context.</td></tr><tr><td><strong>Review and maintain consistency</strong></td><td>Consistency in style, formatting, and level of detail across the codebase is crucial for better readability and understanding. Conduct regular reviews to ensure adherence to Javadoc standards.</td></tr></tbody></table>

<br>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.leapwise.co/backend-handbook/development-practices/javadocs.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
