简体   繁体   English

用Java记录第三方库的使用的标准/官方方式是什么?

[英]What's the standard/official way for documenting the use of a third party library in Java?

When writing a javadoc comment preceding a class in which a third party library is used, what's the standard/official way for documenting the third party library name, version and web address where it can be downloaded? 在使用第三方库的类之前编写javadoc注释时,记录第三方库名称,版本和网址的标准/官方方式是什么? Should it be mentioned in the description or among the block tags (using @see or a custom tag)? 应该在描述中还是在块标记中提及(使用@see或自定义标记)?

Depends on what you want to accomplish. 取决于您要完成的工作。

The version and download link should be in the configuration file of your dependency management tool (such as maven). 版本和下载链接应位于依赖项管理工具(例如maven)的配置文件中。 That way, the documentation is never out of date, and not repeated in every class that happens to use that particular API. 这样,文档永远不会过时,并且不会在碰巧使用该特定API的每个类中重复。

To discover which classes use which API, import statements work quite nicely (yes, one can bypass import statements by using qualified class names, but very few people do, as that makes the source code very hard to read). 为了发现哪个类使用哪个API,import语句可以很好地工作(是的,可以使用合格的类名来绕过import语句,但是很少有人这样做,因为这使源代码很难阅读)。 Alternatively, simply remove the library from the classpath, and see where compilation errors occur. 或者,只需从类路径中删除库,然后查看发生编译错误的位置。

I recommend against documenting this in the javadoc, as the caller of your class should be agnostic of its implementation. 我建议不要在javadoc中进行记录,因为您的类的调用者应该与它的实现无关。 That is, I consider APIs used to be an implementation detail a caller should not know - and what the caller should not know should not be mixed with the things he must know. 也就是说,我认为API曾经是调用者不应该知道的实现细节-调用者不应该知道的内容不应该与他必须知道的东西混合在一起。

Should it be mentioned in the description or among the block tags (using @see or a custom tag)? 应该在描述中还是在块标记中提及(使用@see或自定义标记)?

Just mention it somewhere in the description, (personally) preferably towards the end. 只需在描述中的某处提及(个人),最好在末尾提及。 Don't get into defining custom tags for something like this, it's not worth the hassle. 不要为这样的东西定义自定义标签,这不值得麻烦。 The important thing is that (if necessary) the information is there. 重要的是(如有必要)信息在那里。 There's no set convention for doing this. 没有设定惯例。

I say "if necessary" deliberately - most of the time I'd say this simply isn't needed. 我故意说“如果有必要”-大多数时候我会说根本不需要。 However, if dealing with a library that's not widely known, not in Maven and / or has the tendency to make breaking changes between releases, then it would arguably be worth documenting this at least somewhere. 但是,如果使用的库不是Maven所不熟悉的,并且/或者倾向于在发行版本之间进行重大更改,那么值得至少在某个地方进行记录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我可以在 java 中使用第三方 scala 库吗? - Can I use a third party scala library in java? 使用ArrayList作为Java中的值进行映射-为什么为此使用第三方库? - Map with ArrayList as the value in Java - Why use a third party library for this? Python缺少的Java标准库是什么? - What is it in Java standard library that Python's lacks? 用Java获取第三方库版本 - get third party library versions in Java 将第三方库添加到 Java 小程序 - Adding a Third Party Library to Java Applet 有没有一种简单的方法可以将 java 字符串转换为包括变音符号在内的标题大小写,无需第三方库 - Is there a simple way to convert java string to title case including diacritics, without third party library 如何将第三方Java库编译为我可以使用的jar文件? - How to compile a third party Java library into a jar file I can use? 我(可以)轻松地使用第三方库来处理Java RMI的序列化吗? - Can I (easily) use a third-party library to handle serialization for Java RMI? 如何使用第三方 java 库 github 项目? - How do I make use of a third-party java library github project? 什么是Java核心在2016年创建HTTP连接的官方方式? - What's Java core's official way to create an HTTP connection in 2016?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM