You are invited to name a button
Each coder has its own coding habit. Here’s a small example:
How would you name the control ID of a login button?
- btnLogin
- btLogin
- btn_login
- loginButton
- loginBtn
- denglu
- , etc.
My habit is btnLogin, which style do you have?
Standards matter
When developing an old project of the company, the project iteration has a long history, and the traces of many developers can be seen from the naming style. In a class file, all kinds of naming, it is compulsive to die. I believe that many old projects have such historical legacy problems. Of course, at this point in the history of the future, small teams, even with only one developer in a position, can avoid these problems. When multiple developers work together, it is important to have uniform development specifications, otherwise the problem will continue.
So the question is, how do you make a standard? And that standard needs to be accepted by the whole team to be implemented happily.
It is difficult to persuade people to give up their own style and accept their own naming style. For example, I like btnLogin, my partner likes loginBtn, and I say, “Your name is not good, do mine, and nine times out of ten, I’ll be replayed.” So how to solve this problem? There are two solutions:
- Communicate deeply with your partner and develop a norm.
- Find a current coding specification.
A specification manual is recommended
If you choose option two, I would like to recommend a very authoritative coding specification for you: “Alibaba Java Development Manual”. This development manual is produced by Alibaba, the quality is trustworthy, acceptance and recognition is very high, whether it is now or later developers, are easy to be recognized. At the same time, most importantly, in order to better detect the implementation of the specification, there is also a code specification plug-in, Android Studio can search for installed plugin Alibaba Java Coding Guidelines.
The manual for the specification, do mandatory and recommended grade division, and examples of positive and negative examples, very clear.
The content of the manual is simple and easy to understand. It can be read within an hour. It is used with plug-ins during development, and the experience is great! The plug-in has two detection modes, real-time detection and manual detection. The former reminds us of the specification at any time during the development process, and the latter applies to the overall specification implementation in the investigation project.
There are different alerts for violations, with the enforcement level exploding and the recommendation level warning and providing detailed modification instructions to help standardize the code properly.
This is a mandatory specification:
This is a recommended specification:
Here are the results of manual testing:
A QuickFix is available for some of the errors, which can be fixed with one click (as indicated by the small bulb in the upper right corner of the image). !
It’s never too late
The Manual of Alibaba Java Development manual was officially released on September 9, 2017, and the open source time of IDE code specification testing plug-in was September 25, 2017. It’s July 25, 2018, a very late attempt. But it’s never too late to get better.
No standards can be achieved, and no cooperation can be achieved without norms. For those of you who haven’t formed your own rules yet, try.
PS: background reply “code specification”, you can get a “Alibaba Java development manual” ha.