1. If an API is to be usable, it must be documented.
2. Javadoc generates API documentation automatically from source code with specially formatted documentation comments, more commonly known as doc comments.
3. To document your API properly, you must precede every exported class, interface, constructor, method, and field declaration with a doc comment. If a class is serializable, you should also document its serialized form.
4. To write maintainable code, you should also write doc comments for most unexported classes, interfaces, constructors, methods, and fields.
5. The doc comment for a method should describe succinctly the contract between the method and its client. With the exception of methods in classes designed for inheritance, the contract should say what the method does rather than how it does its job.
6. The doc comment should enumerate all of the method’s preconditions, which are the things that have to be true in order for a client to invoke it, and its postconditions, which are the things that will be true after the invocation has completed successfully. Typically, preconditions are described implicitly by the @throws tags for unchecked exceptions; each unchecked exception corresponds to a precondition violation. Also, preconditions can be specified along with the affected parameters in their @param tags.
7. In addition to preconditions and postconditions, methods should document any side effects. A side effect is an observable change in the state of the system that is not obviously required in order to achieve the postcondition.
8. Finally, documentation comments should describe the thread safety of a class or method.
9. To describe a method’s contract fully, the doc comment should have an @param tag for every parameter, an @return tag unless the method has a void return type, and an @throws tag for every exception thrown by the method, whether checked or unchecked.
10. By convention, the text following an @param tag or @return tag should be a noun phrase describing the value represented by the parameter or return value. The text following an @throws tag should consist of the word “if,” followed by a clause describing the conditions under which the exception is thrown.
11. The Javadoc utility translates doc comments into HTML, and arbitrary HTML elements in doc comments end up in the resulting HTML document.
12. The use of the Javadoc {@code} tag around the code fragment causes the code fragment to be rendered in code font, and it suppresses processing of HTML markup and nested Javadoc tags in the code fragment. To include a multiline code example in a doc comment, use a Javadoc {@code} tag wrapped inside an HTML <pre> tag:
<pre>{@code and follow it with the characters }</pre>
13. {@literal} tag, which suppress processing of HTML markup and nested Javadoc tags. It is like the {@code} tag, except that it doesn’t render the text in code font.
14. The first “sentence” of each doc comment becomes the summary description of the element to which the comment pertains. The summary description ends at the first period that is followed by a space, tab, or line terminator (or at the first block tag). The best solution is to surround the offending period and any associated text with a {@literal} tag, so the period is no longer followed by a space in the source code.
15. When documenting a generic type or method, be sure to document all type parameters.
16. When documenting an enum type, be sure to document the constants as well as the type and any public methods.
17. When documenting an annotation type, be sure to document any members as well as the type itself. Document members with noun phrases, as if they were fields.
18.As of release 1.5, package-level doc comments should be placed in a file called package-info.java instead of package.html.
19.The definitive guide to writing doc comments is Oracle’s How to Write Doc Comments: http://www.oracle.com/technetwork/java/javase/documentation/index-137868.html
相关推荐
Item 56: Write doc comments for all exposed API elements 9 General Programming Item 57: Minimize the scope of local variables Item 58: Prefer for-each loops to traditional for loops Item 59: Know and ...
Xposed-api-82是一个针对Android API级别82(即Android 4.3,Jelly Bean MR2)的Xposed接口库。这个压缩包包含的"api-82.jar"和"api-82-sources.jar"是开发者在编写Xposed模块时需要用到的关键组件。 1. **Xposed...
本文将深入探讨“kotlin-ktor-exposed-postgresql-rest-api”项目,这是一个使用现代技术栈构建的RESTful API,主要涉及的技术包括Kotlin、Ktor、Exposed、HikariCP和PostgreSQL。我们将逐一解析这些技术及其在项目...
根据给定文件信息,本文将针对标题《MGH Hacking Exposed Industrial Control Systems》和描述内容进行详细知识点的阐释。由于没有提供具体的内容章节,因此无法基于实际内容生成知识点。而是根据文件标题和描述所能...
这里的数字"53"通常代表对应的Android版本,意味着这个API适用于Android 5.0(API级别21)至Android 6.0(API级别23)之间。这个JAR包包含了开发者编写XPOSED模块所需的所有类和接口,使得开发者能够利用XPOSED框架...
【Kotlin用户API实验:基于Kotlin,Ktor与Exposed的构建】 在现代软件开发中,RESTful API已经成为构建Web服务的标准方式。本项目“kotlin_users_api”旨在实验性地展示如何使用Kotlin,Ktor和Exposed这三款强大的...
Exposed是Kotlin编程语言中的一款强大的SQL框架,它为开发者提供了简洁、直观的方式来操作数据库。开源项目的特性使得它在社区中得到了广泛的关注和支持,不断更新和完善。本文将深入探讨Exposed框架的基本概念、...
在IT行业中,"EXPOSED"这个词经常被用于表示某个系统、网络或应用程序的安全漏洞被公开,这可能意味着敏感信息的潜在风险。在这个场景下,我们主要关注的是信息安全和字体相关的知识点。 首先,让我们深入了解字体...
exposed-services-ips # Full complete slow scan with output nmap -v -sT -A -T4 -p- -Pn --script vuln -oA full $IP # Autorecon python3 autorecon.py $IP # Scan for UDP nmap $IP -sU unicornscan -mU -v -I ...
该PHP软件包提供了password_exposed帮助函数,该函数使用haveibeenpwned.com API来检查是否在数据泄露中公开了密码。 安装 使用Composer可以轻松安装password_exposed软件包。 只需从项目的根目录运行以下命令。 ...
### 知识点一:《Hacking Exposed Web Applications》第三版概述 - **书籍名称**:“Hacking Exposed Web Applications”第三版。 - **核心价值**:本书为业务领导者、开发人员及安全工程师提供了宝贵的资源,帮助...
Wiley -IT Security Interviews Exposed.pdf
《Android-Exposed:Kotlin打造的轻量级SQL库原型》 在移动应用开发领域,尤其是在Android平台,数据库操作是不可或缺的一部分。而Android-Exposed,作为一个由Kotlin编写的轻量级SQL库,为开发者提供了高效、类型...
- New : StyleElements property exposed Update : TAdvSmoothCalendar v2.3.0.2 - Fixed : Issue with OnSelectMultiDate triggering more than once when selecting multiple dates Update : ...
Hacking+Exposed+Linux
Built-in support for LiveBindings in TTMSFMXTableView and TTMSFMXTileList, allows to bind any item element to data Includes various demos and an extensive PDF developers guide Includes various helper ...
### Syngress.Phishing.Exposed.Nov.2005.pdf 知识点解析 #### 标题:Syngress.Phishing.Exposed.Nov.2005.pdf 该标题表明这是一本由Syngress出版社在2005年11月出版的关于钓鱼攻击(Phishing)的书籍。 #### 描述...
### 知识点一:Hacking Exposed Web Application 概述 - **书籍背景**:《Hacking Exposed Web Applications》是由Joel Scambray和Mike Sheehy合著的一本关于网络安全的重要著作,该书由McGraw-Hill/Osborne出版社...