Read note Two-code specification
The code of the style of the principle is: concise, easy to read, no ambiguity. Although I am a computer science student, but I did not have this principle to write code, now read the construction of the law, I understand how to make your code concise, easier to understand.
The code is noted in the process of writing:
- Indent with TAB key
- Note the line width, up to a limit of 100 characters line width
- In complex conditional expressions, the logical precedence is clearly expressed in parentheses
- Note the {} lines with a line break and blank, with the explicit "{" and "}" to determine the structure of the program
- Do not put too many statements on the same line
- The name of the variable should have a practical meaning
- Use underscores to delimit scope labels and the semantics of variables in variable names
- Variable names that are made up of multiple words in case
- When writing code, be sure to have comments so that others are easy to understand when you look at your code, and that you can easily see your code later.
- When writing a program, be sure to add error handling according to the actual situation, your code becomes more perfect, avoid unnecessary bugs.
Since reading this section, I am deeply ashamed, although I am a computer department student, but I have written before the code opportunity does not conform to any of the above, resulting in my code looks very messy, when the program error, do not know how to start, where to find the wrong, Whenever I let my classmates help me to change the wrong time people are reluctant to think that my code is too messy, variable definition is unclear, the structure is very chaotic. But since I've changed this rule, the code I've written actually seems to be a lot easier to read, to make myself look pleasing, rarely to lose parentheses again, and to use the wrong variable as a low-level mistake.
Writing good rules, neat code, is a good software engineer's first step.
The method of construction--read Note two