In other design fields, the Manual also defines the software design baseline and the need for targeted software design and document precipitation if the threshold is exceeded.

If you are interested in learning more, please refer to the instructions at the end of this article.

Today we also have the honor to invite the author Gu Ju to talk about the story behind the statute and the original intention.



They say we’re brick-moving coders but we know we’re artists who pursue individuality. Maybe we don’t care too much about the way we look and the way we dress but underneath our unruly exterior is the beauty of the code, the beauty of the system and the code specification is actually a definition of the beauty of the program.

But that beauty is far from the life of a programmer, and while the value of coding norms is widely accepted in the industry, it is largely denied in reality. The code that engineers used to be most proud of destroyed trust across the board because of lack of coding specifications, sloppy naming, and serious constraints on efficient collaboration. Frequent system refactorings and nerve-wracking maintenance seem to be the order of the day.

So how to get out of this strange circle? As we all know, the advantage of Internet companies is efficiency, which is the core competitiveness of enterprises. In the field of product development is communication efficiency and r&d efficiency. The importance of effective communication begins with three “programming philosophy battles” among programmers

  1. Should the space or Tab key be used for indentation?
  2. Does an if single line statement need braces or not?
  3. Does the open curly bracket not wrap or start on a separate line?

You may remember the classic scene in Silicon Valley where Richard breaks up with his girlfriend, who is also a programmer, because they have different habits about indentation and the Cody style where they twist and despise each other. The Tab/spacebar controversy does exist in real-world programming. The Alibaba Java Development Manual, hereinafter referred to as the manual, explicitly supports the 4-space approach. If you have to ask a reason, there is no reason because the reason that you can come up with is like the strongest shield. There is always a sharper spear that will Pierce it. Suffice it to say that consistency is important. The time cost of endless debate is inversely proportional to the ultimate benefit.



Whether a single if statement needs a line break is also a matter of debate. Developers of formation-indent programming languages are relatively accustomed to not increasing parentheses. The manual makes it clear that single-line if/for statements must have parentheses because single-line statements are written in a way that creates visual errors when adding logic. There is also the problem of local variable scope if the parentheses are not enlarged.



Does the opening curly brace have a separate line because of the mandatory non-wrapping of the Go language? At this point, the “battle of programming philosophies” doesn’t smell so good. If you had to give a reason you could add one more line of code to a line of code and people in companies that measure work by lines of code would definitely prefer to wrap before the opening curly brace. The Manual specifies that the opening brace is not newline.



The essence of these ideas battles is that I’ve been coding for years and I’m not willing to compromise on a different style and I’m not willing to compromise for the overall efficiency of the team. In fact, there is no objective right or wrong way of programming. Consistency is important. Readability is important.

There is a theory called Parkinson’s Pettiness Law that members of an organization tend to spend too much energy on trivial arguments. Programmers naturally need teamwork and the positive energy of collaboration lies in communicating problems effectively. Personalization should be shown as much as possible in the improvement of system architecture and algorithm efficiency, rather than in the cooperation of the specification of the entangled discussion, debate and finally no conclusion. The rules are different, just like the little duck and the chicken in the picture below.



“Chicken and duck talk” also describes the pain point of communication between people. Here’s another example from life: it doesn’t really matter whether the rules of traffic are better to keep to the left or to keep to the right. What matters is that you have to go in the same direction. On the surface it restricts freedom but in fact it protects the public. Imagine if there were no rules to drive on the right the roads would be so congested and dangerous. Similarly, too much freewheeling, arbitrary code can seriously harm the health of the system and affect scalability and maintainability.

In order to help developers improve the efficiency of r&d, Alibaba Group independently developed a set of automatic IDE detection plug-ins based on the contents of the Manual. The plugin scans the code and displays the code that does not comply with the manual at the bottom of the block/critical/major hierarchy. It also gives you intelligent real-time tips on how to write the code to be more elegant and conform to the common programming style.

Plug-in download address https://github.com/alibaba/p3c



How to Book this book

Copy the following password in Tmall, Taobao APP directly open. The promotional price is less than $25 for lunch in exchange for a lifetime of good coding habits.

Alibaba Java development manual Java language programming tutorial book Java design mode Ali official Java code specification standard Java application development tutorial Java programming 】 (not installed App click here http://zmnxbc.com/s/uvx2d?tm=533ee1) meow password

How can I get this book for free

Talk about the bottom line of software design in the message area you have a chance to get a free signed version of “Alibaba Java Development Manual” limited to 10 people.


The original article was published on December 18, 2017

The author of this article is alone

This article comes from the cloud community partner “Ali Technology” for relevant information, you can pay attention to the wechat public number of “Ali Technology”