Ali Java Code Specification P3C plugin

1 Ali Development Manual

1.1 Description

At the beginning of 2017, the first official Java code standard manual of Ali was released, which can be said to have caused the upsurge of the code standard of all people (IT circles). I believe this manual is familiar to many friends in the industry. It ’s hard to be low-key. The main purpose of this manual is:
“Code efficient, code quality. Unify the standard, improve the standardization of industry coding, help industry personnel improve development quality and efficiency, and reduce code maintenance costs.”

1.2 Development Manual

"Alibaba Java Development Manual" is the collective wisdom and experience of Alibaba Group's technical team. It has undergone many large-scale front-line battle tests and continuous improvement. It has been systematically organized into a volume and returned to the developers. The rapid development of the modern software industry requires more and more comprehensive quality of developers, because not only programming knowledge points, knowledge points of other dimensions will also affect the final delivery quality of the software. For example: database table structure and index design defects may bring software architecture defects or performance risks; chaotic engineering structure leads to subsequent maintenance difficulties; unauthenticated vulnerability codes are vulnerable to hacker attacks, etc. Therefore, this manual takes Java developers as the central perspective and is divided into seven dimensions: programming protocol, exception log, unit test, security protocol, MySQL database, engineering structure, and design protocol, and then is subdivided into several sub-directories according to the content characteristics. . According to the binding strength and fault sensitivity, the statute is divided into three categories: mandatory, recommended, and reference. For the extended information of the statute items, "Explanation" appropriately expands and explains the statute; "Code" promotes what kind of coding and implementation; "counterexample" explains the minefield that needs to be guarded against, and real error cases.

The purpose of this manual is to express high efficiency and quality. The complexity of modern software architecture needs to be completed by collaborative development. How to collaborate efficiently? There are no rules and no rules, and no rules are difficult to coordinate. For example, the formulation of traffic laws on the surface is to restrict the right to drive, in fact, to protect the personal safety of the public. Imagine if there is no speed limit and no traffic lights, who dares to go on the road. For software, proper specifications and standards are by no means to eliminate the creativity and elegance of the code content, but to limit excessive personalization, work together in a generally accepted and unified way, improve collaboration efficiency, and reduce communication costs. The blood of the software system flows between the lines of the code. The quality improvement is to step on the pit as little as possible, to avoid stepping on the repeated pits, and to effectively improve the stability of the system and the quality of the code. Considering that you can interact with many development students from a distance, it is decided to maintain the content of the Manual online in the future. This PDF version of 1.4.0 is the most detailed version, adding a large chapter of the design specification and adding several items; we have already Alibaba Java development protocol plug-in was released at the 2017 Hangzhou Yunqi Conference, and Alibaba Cloud Effect also integrated a code protocol scanning engine.

Download the latest version of the manual : http://click.aliyun.com/m/1000019584/The
story behind the development manual : https://v.youku.com/v_show/id_XMzgzNzIwOTgxNg==.html?spm=a2h0k.11417342.soresults .dtitle
Insert picture description here

2 Ali P3C

2.1 Description

The code specification check plug-in P3C is an automated plug-in converted from the "Alibaba Java Development Manual".

2.2 What is P3C

P3C was originally a model of maritime patrol aircraft. The large fuselage can carry a large number of electronic devices, there are ten weapon attachment points under the wing, and eight internal bomb bays under the belly, which can carry AGM-65 air-to-ground missiles, AGM-84 anti-ship missiles, MK-46 / 50 torpedoes and MU -90 torpedoes, deep-water bombs, mines, etc .; used to perform maritime missions such as reconnaissance, anti-submarine, anti-surface, surveillance and patrol. The code world specializes in dealing with newbies and old fritters.

2.3 Introduction

"Alibaba Java Development Manual" has attracted much attention from the industry since the first version. I believe many people have a certain understanding of the rules. Many people even hope to implement it in their own team as soon as possible. Set of common development guidelines. However, how to better comply with the rules and develop our system according to the manual is indeed not so easy. In order for developers to promote and implement the specifications more conveniently and quickly, Alibaba has developed a set based on the content of the manual Automated IDE detection plug-in (IDEA, Eclipse), after scanning the code, the plug-in will display the code that does not meet the "manual" in the following three levels of Blocker / Critical / Major, even on IDEA, it is also provided based on Inspection Real-time detection function, you can quickly find the problem while writing code. For historical codes, some rules have realized the function of batch one-click repair, which improves the code quality and improves the team's research and development efficiency.

3 IDEA and Eclipse install plugin

3.1 IDEA installation method 1 (recommended)

Open IDEA, File-> Setteings-> Plugins-> Browse Repositories, search for Alibaba in the Browse Repositories search bar, and then
Insert picture description here
Insert picture description hereclick after installation, Restart IntelliJ IDEA

3.2 IDEA uses installed plugins

After installation, use method: open IDEA, click tools—> installed Ali coding protocol, you can choose Chinese and English to switch, right click on the project and select the coding protocol to scan to see where your coding is not good enough, you can quickly locate and modify it.
Insert picture description here
Insert picture description here
If you think Ali ’s prompt is too strict, we can also choose to check the constraints, File-> Settings-> Editor-> inspections, you can choose constraints according to your own requirements
Insert picture description here
3.3 Automatically generate comments when creating key classes

The Ali manual clearly states that the author of each class needs to be annotated. In case the code goes wrong or is not standardized, the programmer can be caught at once. If your code is good enough, it is easy to stand out in the team.
Insert picture description here
3.4 Automatic formatting code when saving
Insert picture description here
3.5 IDEA install plug-in method two

Plug-in download : http://click.aliyun.com/m/1000019585/After downloading the plug-in separately, import IDEA and restart IDEA Detailed operation

3.6 Eclipse installation plugin

The IDEA function table is powerful, and I have not used eclipse for a long time. For those who have not used IDEA, I suggest you try it, and you will definitely love IDEA. The following pictures are from other blogs, you can refer to it. Import code style formatted
source code download : https://github.com/alibaba/p3c/tree/master/p3c-formatter
Insert picture description here

Import code format file
Insert picture description here

3.7 Using plugins

Click the icon on the upper left of eclipse to scan the Alibaba code protocol. If it is not available, click Switch Language, then switch back and restart.
Insert picture description here

Attached:

Note: Some pictures in this blog post are from other blogs. If infringement, contact must be deleted.

Released six original articles · won praise 0 · Views 4853

Guess you like

Origin blog.csdn.net/weixin_44479378/article/details/103028942