The previous article received the attention of many friends, both of whom were derogatory and sincerely happy. Several of them mentioned that good source code is hard to find. In fact, from my point of view, reading a program is not good or bad. A good source code is really easy to read and understand, and even easy to understand. A bad source code is confusing and even disturbing. However, as a learner, you should keep a calm mind, it is good at getting fun from others' mistakes or chaos. After all, it can be seen that others' mistakes can prove that their own levels are high. reading programs and discovering errors is also a learning process. Programmers are a profession that requires continuous learning and innovation. Outsiders often think about it and often ot (working overtime). Someone once described it as follows: if there is a shadow shaking on the street in the middle of the night, there are only two possibilities: either a dust girl or a programmer. Well, I do not know whether it is good or bad. Is it true or not? At least it means that we are working hard. In fact, the first reason we have worked hard is to keep ourselves out of date, and our technology is getting new and faster, so we will be out after a little bit of downtime, second, in order to write better and more valuable programs and make the company make more money, boss is happy, and we are happy. So how can we write excellent programs? In his book, winberger talked about the elements of excellent programs, including functionality, timeliness, adaptability, efficiency, and economics. I believe everyone is familiar with the previous four points, let's make a simple description. Any project, product, or program may have a clear goal, that is, to meet certain functional requirements. programmers must understand it thoroughly and never be ambiguous. Otherwise, they will work hard, even if the program is beautiful and efficient, but it is not required by the customer and has no value, it can be said that if a program does not meet functional requirements to a certain extent, therefore, the evaluation of adaptability, efficiency, and development cost will be meaningless. The time here refers to whether the development of a program can be completed according to the expected time of the development plan? This is a problem that we often face. The delay in completing the program results in serious losses. In addition to economic losses, it is easy to cause uncontrolled management confusion. In a word, annoying things will come one after another. Maybe you can read this article to understand why 50% of the shadows shaking in the streets in the middle of the night may be programmers? Even so, it is hard to see programs that can be completed on time, especially in domestic IT enterprises, it is estimated that there are more than 80% programs (projects or products) it cannot be completed within the scheduled time. Therefore, the completion of a program that can be called an excellent one is an important deciding factor. During program development, the programmer's mind has a concept of time in addition to code. A mature and stable Program (project or product) is mostly used and constantly improved over the years. It is quite common to modify the program, and it is difficult to modify the program, it is also one of the factors to measure program excellence. If a program does not need any modification, it can be used normally in any other software system on any platform environment. This is a wonderful thing. In fact, we have been pursuing this kind of result, during program development, we should fully consider the issue of code adaptability and strive to make self-compiled programs (components, classes, modules, and so on) highly adaptive. In the future, we should make fewer modifications in use, easy to modify. Too much emphasis on the versatility and ease of modification of the program will often lead to program efficiency problems, which may be slow and consume resources. This is really a contradiction. In the words of Master Winnie, it is described: "It requires the program to be highly efficient and adaptive at the same time, just as we hope to find a beautiful and humble wife", haha, this dream is obviously very difficult to achieve, although beauty and humble beauty are not none, as an ordinary programmer, we usually need to make a trade-off between the two, or it is good to balance them, mm, which is not very beautiful but humble, is also a good choice. In fact, you may often encounter and think about the previous four points. The last point is the economy that I am interested in and need to emphasize. Before writing this article, I have just finished my research on the recently released Forbes China rankings. Most of the top 100 were actors, singers, athletes, hosts, directors, models, and other big names, unfortunately, I did not find it people. I don't know what I want to do. I want to see what I want to do with my Uncle Li Yanhong. I have been the richest man in the world for 12 years. We have to admire him, we also look forward to having a few IT jobs among the first 100 people a day, so we can be complacent. In his opinion, the new factor that determines the quality of code is the economy. Many non-Programmers think that Bill Gates is the greatest and best programmer in the world. Because his or his company's programs make the most money, the truth is that it is so easy to understand, sometimes I may even doubt whether my motivation for doing this is for interest, earning money, or both. But who is more important? In the years when I first started working, I often sneered at the software products of my company. In my opinion, it was a pile of rubbish, but it was incredible that I could earn a lot of money! But the reality is often the same. Microsoft Dongdong is good, but it is also Constantly patching and upgrading. We even often find windows or office or large or small bugs, however, this does not affect Microsoft's sales revenue. Yes, we cannot write a perfect program. As long as it does not affect the normal use of important functions, we must discard some things first, we cannot lose the market lead because of our pursuit of perfection. What is the purpose of making money if the program is well written? The above is a general discussion from a big point of view. Before we end this article, let's summarize some points worth attention from the details: (1) Develop a good annotation style: including comments of files, functions, and important code; (2) code indent: each nested function block uses a tab indent (three spaces can be set ), braces should be placed in the next line of the Condition Statement and separate into one line to facilitate matching (mainly for C/C ++, VC ++). (3) use the Hungarian name method as much as possible for variables, at the same time, combined with the principle of development tools, variables are generally named as: <scope> <prefix> <qualifier> (4) develop the habit of writing program documents; (5) be good at using components to implement a specific function. (6) data layer and business logic layer are independent of each other. (7) Use less global variables and less pointers. (8) Avoid using extern, disable Goto. Add # ifdef in debug .. # endif ..............
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.