- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
我应该为我的所有 java 方法编写文档注释吗?
最佳答案
@克劳迪乌
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.
@丹尼尔·斯皮瓦克
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.
@保罗·德弗里兹
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;
}
是的,这是更多的工作。
@VonC
当你把一个巨大的复杂方法(因为high cyclomatic complexity的原因)分解成:
,javadoc 私有(private)方法也非常有用,即使该文档在 javadoc API 文件中不可见。
尽管如此,它仍然可以让您更轻松地记住复杂算法的不同步骤的精确性质。
记住: limit values or boundary conditions 也应该是您的 javadoc 的一部分。
另外,javadoc 比简单的“//comment”要好得多:
@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.
@米格尔平
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.
关于java - 您编写的每个方法都使用 Javadoc 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/211041/
我有多个程序员为 javadocs 贡献示例,一些示例包含格式化为 /* * */ 当我将这些示例放入 javadoc 注释时,示例中的注释 close 将关闭 javadoc 注释。 /**
我目前有一些 Source and Javadoc on GitHub .您可能知道,无法在 GitHub 上查看(呈现的)HTML 页面。但是solutions为这个问题而存在。就在一天前,这个解决
我希望能够使用@nnotations 来标记要从 javadoc 中排除的类或方法。 有没有办法为此目的对标准 doclet 进行子类化?第一次浏览 javadoc-doc 没有揭示解决方案。 最佳答
我正在生成 Javadocs。现在我想自动将所有库和 JDK 类链接到该库或 JDK 的官方文档。这可能吗?如果可以,我需要哪个命令行参数 最佳答案 解析对标准 Java 类的引用需要您拥有 Java
我正在生成 Javadoc。现在我想自动将所有库和 JDK 类链接到该库或 JDK 的官方文档。这可能吗,如果是的话,我需要哪个命令行参数 最佳答案 解析对标准 Java 类的引用需要您拥有 Java
我想在我的 javadoc 中使用自定义标签,但要遵守某种约定,以便其他人可以更轻松地理解它们。在 Oracle 的官方 javadoc 文档页面上,他们列出了基本标签,与我的编辑器的 javadoc
我在 javadoc 中的代码示例中有一个 @: * * public class ArticleService { * @Autowired * private Artic
如果您有几个不同项目的标准 Javadoc,您如何处理它们以创建一个统一的文档集,其中所有内容都是交叉链接的?理想情况下,结果将类似于 NetBeans 平台中各种模块的文档: http://bits
我正在尝试将现有的 Javadoc 修复到 project . 我在运行 mvn javadoc:fix .它成功执行但没有修复一些 Javadocs。 Maven Javadoc插件的配置: [DE
我正在尝试为多模块项目创建聚合 javadoc。该项目使用 mvn install -DskipTests 编译(我没有在我的机器上运行测试)。当我运行 mvn validate javadoc:ja
当我这样做时,我收到以下错误 mvn clean deploy -DperformRelease=true [ERROR] Exit code: 1 - .java:3: package javax.
我有一个带有 maven-javadoc-plugin 和 JDK8 的 Maven 项目。当我运行 mvn javadoc:test-javadoc 时,插件会报告文档错误并停止,但是当我运行 mv
我们使用 swagger 代码生成来创建客户端 API,代码库是用 java 8 编写的,我们现在升级到 java 11。我们使用 2.4.15 版本的 swagger-codegen-cli。代码生
过了一会儿,我回来写 JavaDoc。与此同时,我开始喜欢 SO 的标记,它在纯文本中比 HTML 更具可读性。 (即使是我以前从未使用过的反勾号)。 /** * I'm talking about
我有以下依赖项并在我的 pom 文件中构建。我可以使用 Maven 命令手动创建 javadoc。我也可以成功执行构建。输出根本没有提到 javadoc。我还尝试省略输出目录路径。 POM文件依赖部分
如何在 gitlab 中发布 javadoc?到目前为止,我已将 javadocs html 页面添加到 repo,但是当我尝试查看它们时,会显示原始文本 html 源,而不是重新编辑的 html 页
我在 Eclipse 中使用 Jsoup 时遇到了这个问题。我附上了以下 jar 文件:jsoup 1.7.2.jarjsoup 1.7.2.javadoc.jarjsoup 1.7.2.source
我正在尝试修复我的项目的javadoc(主要缺少@param和@return值),并且由于有相当多的代码需要修复,我正在尝试使用javadoc:fix目标: mvn javadoc:fix 不幸的是,
有什么东西可以用来解析 JavaDoc,以便我可以在运行时通过标准 Doclet 接口(interface)对其进行操作吗?本质上,一个 Doclet 的反向操作. 我知道不可能为每个 Javadoc
由于 TypeScript 不支持压缩或混淆,而这两者都是我们需要的功能,因此我们的工具链中仍然需要像 Google 的 Closure 编译器这样的工具。有没有办法让 TypeScript 自动输出
我是一名优秀的程序员,十分优秀!