The beauty of programming in the ecmboss Enterprise Content solution project series (III)

Source: Internet
Author: User

If the software system architecture is a human skeleton and the programming language is human skin color, the code is human appearance. For a software engineer, he thinks not only about his own beauty, but also about his programming beauty. If he wants to surpass himself and reach a higher level, what he wants to do is not just a job, but a complete system function. He should be able to write clean code, thinking code and soul code are what we call the beauty of programming. The beauty of programming lies in Cleanliness If the internal structure of a software product cannot be changed once it is formed like a hardware product, there is no need to strictly review the code. However, software products can be replicated and must be updated frequently. Therefore, we need to make the software code as beautiful as we are. In this way, when others maintain our code, they will not delete it because they do not understand the code. A good piece of code should first have a neat form. Clean code should be a code block that does not include unnecessary comments, uses code formatting without disorder, and removes warnings on the page as much as possible. Programmers who are writing programs at the beginning are always lazy to write comments. After several criticisms by the leaders, the whole page is often commented. Correct comments should be comments for methods and obscure struct, rather than too many comments in methods or cyclic structures. Some programmers often use the format provided by the compiler to format the code because it is easy to figure. However, for some long sentences, the code after formatting by the compiler may not be easy to read. Therefore, you cannot use code formatting, but do not use code formatting in disorder. The warning will not affect the operation of the system, but there is! Does it affect code compilation or system running. But what I want to tell you as a person who has passed through is that giving your code no warning is definitely one of the ways for your leaders to look at you differently. The beauty of programming lies in the StructureA good piece of code should first have a good structure and follow the rules of High Cohesion and low coupling. Maybe when you are programming, the system architect has determined the system architecture, and all the coding work you do is done according to the system architecture, you think that all the code you write is in line with the system structure, but have you ever thought about what kind of code is code with a good structure. Calls between the system architecture layer and layer are only part of the structure, and are still part of the system structure within each layer. For example, for the service layer that we often write, what we need to do at this layer is to complete an independent function. While we guarantee the transaction, call multiple methods on the DaO layer. This is an independent structure. Sometimes, a method is too powerful to complete and the entire code block is too large. At this time, we need to consider extracting some public independent methods as private methods at the service layer, to complete this function. The beauty of programming lies in the soulTo write a poetic code, we need to make the code spiritual. How can we write a code with a soul? First of all, on the basis of the beauty of cleanliness and structure, the programmer's ideas are incorporated into the code, not just the mummy that reflects the function. With spiritual code, we should first be able to face the world, that is, to achieve international support. Although internationalization only displays the corresponding content in different languages, but how many people truly achieve perfect international support? If there is a spiritual code, we should handle constants flexibly. Chinese often experienced coding errors during the conversion process at the front end. We put these constants in the data dictionary to prevent such problems. With spiritual code, you should also be able to handle exceptions in a unified manner. When an exception occurs in the system, we need to be able to catch and throw in a timely manner. It is best to have a class dedicated to exception handling, although the system already has an exception class, we use our own exception classes to handle exceptions, so that we can promptly discover system exceptions and report the correct information to users. The beauty of programming lies in the programmer's mindSometimes, the project is too tight, and leaders are always pushing the progress. We often Ctrl + C to implement the function. although the functions of the system are implemented, the beauty of cleanliness and structure is lost, let alone the beauty of soul. If we want to keep our code permanently, we want our code to be blamed by leaders, and we want our code to be praised by leaders, optimize Your code in the free time of daily work to make your code as beautiful as you are. The beauty of programming, there are many more beautiful places to discover by yourself.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.