Abstract:Due to busy work, many people only focus on implementing the basic functions of the program, while ignoring programming specifications. The result is that the written code is hard to understand, and even reading their own code is very difficult, this results in a waste of time and reduced work efficiency. The code written by experts is easy to understand. How can we do it like them?
"The first is programming for people, and the second is computer", which is the basic point of software development, the software life cycle runs through long-term processes such as product development, testing, production, release, user usage, version upgrade, and maintenance, only easy-to-read and easy-to-maintain software code is vital.
In the actual software development process, it may be because of busy work. Many developers only focus on implementing the basic functions of the program and forget the programming specification, therefore, the written code can only be understood by the computer. It is not easy for people to understand the code. What's more, some project teams explicitly require the team members to implement product functions in order to catch up with the progress, and the code can be run. Low requirements generate low-quality code. Since "Header" requires this, is it necessary to write code that is "readable?
If not programmed, what are the consequences?
The progress is catching up, and the product is delivered. Everything seems OK, but the problem also arises. There are frequent product faults in front of the system, and developers are not stopping. At this time, they discovered that the code written by others was difficult to understand, and even they were very difficult to read their own code. If the code can be standardized at the beginning, and the documentation is well-equipped, why?
"Good" code and "bad" Code make people feel very different. When we see beautiful code, we will have a desire to continue researching, and even a feeling of enjoyment. On the contrary, when we see ugly code, we will bite our teeth, because it is not only not conducive to reading, but also waste a lot of time, reducing the efficiency of our work.
Generally, the "good" code and "bad" Code give us the following impressions:
Typographical neat vs typographical not neat
When we open a code file, what we first see is how it is typeset, which is also the most intuitive feeling. When code formatting is neat, we can easily find out its logic and logic, and quickly understand what functions it actually wants to implement. When the formatting is not neat, our eyes will feel tired, this affects our thinking.
Naming Conventions vs naming irregularities
After reading the layout, we will see the name of each function and variable. Generally, projects have a large number of lines of code, so it is impossible for us to spend a lot of time understanding what each function and variable is intended for and what it is. This requires us to make the names of functions and variables descriptive During encoding so that they can tell readers what they are doing, instead of having to spend a lot of time studying it. This reflects the developer's attitude and degree of professionalism to a certain extent.
For example, a message processing function named processmsg and functiona is better? It is obviously the former. As soon as we see its name, we will know what it is.
For another example, there are three variables named returnvalue, maxnum, and sumoftwonum, so we can understand their functions at once. The first variable is used as the return value, the second variable is used to store the maximum number, and the third variable is used to store the sum of the two numbers. This is too obvious. You don't have to ask Yuan Fang to figure it out on your own.However, if you name the three variables I, j, and K at the same time, you will not be able to see at a glance what they are for, and it will take a lot of time to read the code, you don't even know how to use it for a few hours. At this moment, your old man asked you how you did things. When you say it, he said you were incompetent.In fact, you are a "dumb eating berberine", and it is strange that others did not write the code.
Properly commented vs not allowed
After reading the code, we will also check whether there are comments and whether there are many or few comments. This is also intuitive.
If the functions implemented by the Code are complex, it is essential to add comments. When appropriate comments are used to make readers feel that their ideas are suddenly open, they will silently appreciate you.Too few or no comments are required, just as if we were eating. If there is nothing in a bowl of vegetables, you will feel boring and have no appetite. If you put a little chili sauce on it, you will feel a doubling of appetite. Believe it or not, I believe it.
However, there cannot be too many comments, so it cannot hide useful code, and it cannot be overwhelming, so that the code that truly implements the function can be used as a foil.
Programming: how can we write good code that allows "people" to understand?
So, how do we write the "good" code that can be understood by "people? This process cannot be achieved overnight. We need to step by step, start from me, start from the side, and constantly improve the realm of personal programming.
In my opinion, you can consider the following aspects:
First, train new employees on software programming specifications.In their initial work, let them strictly follow the programming specifications to write code. The sooner you start programming specification training, the sooner you get into the habit of writing standard code, the clearer the code you write. By the way, many IT companies do not have this awareness. They only need to train their corporate culture so that they can increase employee loyalty. In fact, this is just a whimsical practice.
Second, we will regularly discuss topics on program specifications in the project team to strengthen everyone's awareness.The code written by the old employee demonstrates the role of the new employee. If the program written by the old employee is poorly readable, what would the new employee think? What will they do? Many developers only work hard every day, but ignore some of the most basic things, so it is difficult to improve their capabilities again. After writing the code, do not just think that the task is finished, but also write some project documents, such as detailed design documents, unit/integration testing documents. In these documents, you can clearly write your own ideas so that you or others can quickly understand the program ideas.
Third, developers write code in strict accordance with the company's programming specifications.How to name variables? How to name a function? How do I write annotations? How is code typographical? These have strict requirements. As a qualified software development engineer, writing standard code is a basic requirement. When we read beautiful code, do we feel very comfortable? To some extent, the degree of code writing standards can reflect a programmer's attitude and professionalism.
Fourth, the project team should strictly carry out the peer review process.Most IT companies have a process called "Peer Review" to improve the quality of their products, that is, to allow project team members to check their respective results and learn from each other, learn from each other, and improve their performance together. However, it may be due to the influence of Chinese culture, and everyone is more concerned about face-to-face. Therefore, they are reluctant to express their true thoughts on others, making "Peer Review" a mere formality. Of course, if you do not have any opinions on other people's programs, let alone. Being open and honest with others is not an offense, but a good way for everyone to learn from each other.
Fifth, the most important thing is that individuals must be aware of writing standard code and constantly learn various techniques to improve programming capabilities.No matter what others say to you, if you do not want to write the program, what if you do not want to write the program? Although programmers are very busy at work, they also need to take time to learn new technologies so that they will not be eliminated by new technologies.
"Sometimes, the sky is everywhere." For many people, it is enough to write programs that can be understood by computers. However, if you want to become an excellent software development engineer, therefore, we must strive to write code that makes it easy for "people" to understand and understand. This is a long-term process. Everyone must have preparations for the long journey and the spirit of moving yugong to the mountains.