zoukankan      html  css  js  c++  java
  • 阿里巴巴Java开发手册(华山版)

    插件下载地址:

    https://github.com/alibaba/p3c

    2018年9月22日,在2018杭州云栖大会上,召开《码出高效:Java 开发手册》新书发布会,并宣布将图书所有收益均捐赠于技术公益项目“83行代码计划”。

    阿里巴巴正式在2018杭州云栖大会《开发者生态峰会》上,由阿里巴巴高年级同学中间件负责人林昊、阿里巴巴研究员刘湘雯、阿里巴巴研究员刘国华,OpenJDK社区Committer杨晓峰,全栈视障工程师蔡勇斌,电子工业出版社博文视点出版公司总经理郭立以及两位图书作者杨冠宝(孤尽)和高海慧(鸣莎)重磅大咖联合发布新书《码出高效:Java开发手册》(跳转至天猫书店),并宣布将图书所有收益均捐赠于技术公益项目“83行代码计划”,第一个“83行代码计划”行动,将围绕着帮助盲人工程师,开发更多无障碍化产品,让盲人上网更便捷。未来,我们会坚持用技术为公益行业赋能,也希望更多人成为技术受益者<

    2017年10月14日杭州云栖大会,Java代码规约扫描插件全球首发仪式正式启动,规范正式以插件形式公开走向业界,引领Java语言的规范之路。目前,插件已在云效公有云产品中集成,立即体验!(云效>公有云>设置->测试服务->阿里巴巴Java代码规约)。

    P3C

    License

    Preface

    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. Another example is confusing code structures being difficult to maintain. Furthermore, vulnerable code without authentication is prone to hackers’ attacks. To address these kinds of problems, we developed this document for Java developers at Alibaba.

    For more information please refer the Alibaba Java Coding Guidelines:

    Introduction

    The project consists of 3 parts:

    Rules

    Forty-nine rules are realized based on PMD, please refer the P3C-PMD documentation for more detailed information. Four rules are implemented within IDE plugins (IDEA and Eclipse) as follows:

    • [Mandatory] Using a deprecated class or method is prohibited.
      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.

    • [Mandatory] An overridden method from an interface or abstract class must be marked with @Override annotation. 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.

    • [Mandatory] A static field or method should be directly referred by its class name instead of its corresponding object name.

    • [Mandatory] The usage of hashCode and equals should follow:

      1. Override hashCode if equals is overridden.
      2. These two methods must be overridden for Set since they are used to ensure that no duplicate object will be inserted in Set.
      3. These two methods must be overridden if self-defined object is used as the key of Map. Note: String can be used as the key of Map since these two methods have been rewritten.

    Join us

    If you have any questions or comments, please contact junlie by email at caikang.ck@alibaba-inc.com, and please join us to make project P3C perfect for more programmers.

    Please follow our WeChat official account as ali_yunxiao below:

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    Eclipse Plugin


    Prepare

    • Eclipse Juno+
    • maven3.+
    • JDK 1.7+

    ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

    eclipse 文档 JPA问题说明

     
     

    首先非常感谢大家对插件的支持与意见,Eclipse的功能相对来说比较简单,希望有更多的同学加入进来一起完善。

    插件安装

    环境:JDK1.8,Eclipse4+。有同学遇到过这样的情况,安装插件重启后,发现没有对应的菜单项,从日志上也看不到相关的异常信息,最后把JDK从1.6升级到1.8解决问题。

    Help -> Install New Software...

    输入Update Site地址:https://p3c.alibaba.com/plugin/eclipse/update 回车,然后勾选Ali-CodeAnalysis,再一直点Next Next...按提示走下去就好。 然后就是提示重启了,安装完毕。

    注意:有同学反映插件扫描会触发很多 "JPA Java Change Event Handler (Waiting)" 的任务,这个是Eclipse的一个bug,因为插件在扫描的时候会对文件进行标记,所以触发了JPA的任务。卸载JPA插件,或者尝试升级到最新版的Eclipse。附:JPA project Change Event Handler问题解决

    插件使用

    目前插件实现了开发手册中的53条规则,大部分基于PMD实现,其中有4条规则基于Eclipse实现,支持4条规则的QuickFix功能。

    * 所有的覆写方法,必须加@Override注解, 
    * if/for/while/switch/do等保留字与左右括号之间都必须加空格,
    * long或者Long初始赋值时,必须使用大写的L,不能是小写的l)
    * Object的equals方法容易抛空指针异常,应使用常量或确定有值的对象来调用equals。
    

    目前不支持代码实时检测,需要手动触发,希望更多的人加入进来一起把咱们的插件做得越来越好,尽量提升研发的使用体验。

    代码扫描

    可以通过右键菜单、Toolbar按钮两种方式手动触发代码检测。同时结果面板中可以对部分实现了QuickFix功能的规则进行快速修复。

    触发扫描

    在当前编辑的文件中点击右键,可以在弹出的菜单中触发对该文件的检测。

    在左侧的Project目录树种点击右键,可以触发对整个工程或者选择的某个目录、文件进行检测。

    也可以通过Toolbar中的按钮来触发检测,目前Toolbar的按钮触发的检测范围与您IDE当时的焦点有关,如当前编辑的文件或者是Project目录树选中的项,是不是感觉与右键菜单的检测范围类似呢。

    扫描结果

    简洁的结果面板,按规则等级分类,等级->规则->文件->违规项。同时还提供一个查看规则详情的界面。

    清除结果标记更方便,支持上面提到的4条规则QuickFix。

     

  • 相关阅读:
    Python常用内置函数整理(lambda,reduce,zip,filter,map)
    C#中Hashtable容器的了解与使用
    关于ref与out的区别
    关于多线程学习总结(五) 线程池
    关于多线程学习总结(四) 锁
    关于多线程学习总结(三) 线程简单基本操作
    关于多线程学习总结(二) 了解线程的属性及方法
    关于多线程学习总结(一) 基本概念了解
    CSS文件和Javascript文件的压缩
    看几道JQuery试题后总结(下篇)
  • 原文地址:https://www.cnblogs.com/zouhao/p/12054655.html
Copyright © 2011-2022 走看看