|
1 |
| -## 代码规约插件全球首发 |
2 |
| - |
3 |
| -10月14日杭州云栖大会上会,代码规约插件及源码,将在杭州云栖大会上[研发效能峰会](https://yunqi.aliyun.com/2017/hangzhou/meeting?day=day4&theme=all&meeting=detail1433 )的首发仪式上全球首发。 |
| 1 | +Java代码规约扫描插件已在[研发协同RDC](https://rdc-test.aliyun.com)(云效公有云解决方案)的测试功能中实现(设置->测试服务->阿里巴巴Java代码规约)。 |
4 | 2 |
|
5 |
| -过去的整整一年中,阿里内部经历过无数次针锋相对的讨论,与实战经验相结合,系统性地从编程,数据库,异常日志,工程结构,安全,单元测试(new)六个维度总结做为Java合格开发者必备的技术素养。只是文档让开发同学遵守是非常困难的,阿里研发一套自动检测插件——代码规约扫描插件,已在[研发协同RDC](https://rdc-test.aliyun.com/)(云效公有云解决方案)的实验室功能中实现。 |
| 3 | +# P3C |
6 | 4 |
|
7 |
| -[](https://rdc-test.aliyun.com) |
8 |
| -点图可在线扫描代码合规情况 |
| 5 | +[](https://www.apache.org/licenses/LICENSE-2.0.html) |
9 | 6 |
|
10 |
| -“开发手册”主要作者孤尽在10月13日的云栖大会上分享“从推动的Java的代码规约谈技术人成长的有所为”,欢迎大家到场零距离沟通。 |
| 7 | +## <font color="green">Preface</font> |
| 8 | +> We are pleased to present Alibaba Java Coding Guidelines, which consolidates the best programming practices over the years from Alibaba Group's technical teams. A vast number of Java programming teams impose demanding requirements on code quality across projects as we encourage reuse and better understanding of each other's programs. We have seen many programming problems in the past. For example, defective database table structures and index designs may cause software architecture flaws and performance risks. Yet as another example, confusing code structures make it difficult to maintain. Furthermore, vulnerable code without authentication is prone to hackers’ attacks. To address those kinds of problems, we developed this document for Java developers in Alibaba. |
| 9 | + |
| 10 | +For more information please refer the *Alibaba Java Coding Guidelines*: |
| 11 | +- 中文版: *[阿里巴巴Java开发手册](https://github.com/alibaba/p3c/blob/master/%E9%98%BF%E9%87%8C%E5%B7%B4%E5%B7%B4Java%E5%BC%80%E5%8F%91%E6%89%8B%E5%86%8C%EF%BC%88%E7%BB%88%E6%9E%81%E7%89%88%EF%BC%89.pdf)* |
| 12 | +- English Version: *[Alibaba Java Coding Guidelines](https://alibaba.github.io/Alibaba-Java-Coding-Guidelines)* |
11 | 13 |
|
12 |
| -电子工业出版社也将在一年后出版孤尽参与编写的“码出高效 - 阿里巴巴的Java开发手册详解”这本书。 |
| 14 | +## <font color="green">Introduction</font> |
| 15 | +The project consists of 3 parts: |
| 16 | +- [PMD implementations](p3c-pmd) |
| 17 | +- [IntelliJ IDEA plugin](idea-plugin) |
| 18 | +- [Eclipse plugin](eclipse-plugin) |
13 | 19 |
|
14 |
| -代码规约最新更新消息关注“代码规约”微信公众号: |
| 20 | +## <font color="green">Rules</font> |
| 21 | +<font color="blue">49 rules are realized based on PMD, please refer the P3C-PMD documentation for more detailed information. 4 rules implemented within IDE plugins (IDEA and Eclipse) as following:</font> |
15 | 22 |
|
16 |
| - |
| 23 | +- ``[Mandatory]`` Using a deprecated class or method is prohibited. |
| 24 | + Note: For example, decode(String source, String encode) should be used instead of the deprecated method decode(String encodeStr). Once an interface has been deprecated, the interface provider has the obligation to provide a new one. At the same time, client programmers have the obligation to check out what its new implementation is. |
| 25 | + |
| 26 | +- ``[Mandatory]`` An overridden method from an interface or abstract class must be marked with @Override annotation. |
| 27 | + Counter example: For getObject() and get0bject(), the first one has a letter 'O', and the second one has a number '0'. To accurately determine whether the overriding is successful, an @Override annotation is necessary. Meanwhile, once the method signature in the abstract class is changed, the implementation class will report a compile-time error immediately. |
| 28 | + |
| 29 | +- ``[Mandatory]`` A static field or method should be directly referred by its class name instead of its corresponding object name. |
| 30 | + |
| 31 | +- ``[Mandatory]`` The usage of hashCode and equals should follow: |
| 32 | + 1. Override hashCode if equals is overridden. |
| 33 | + 2. These two methods must be overridden for Set since they are used to ensure that no duplicate object will be inserted in Set. |
| 34 | + 3. These two methods must be overridden if self-defined object is used as the key of Map. |
| 35 | + Note: String can be used as the key of Map since these two methods have been rewritten. |
0 commit comments