4. efficient programming: Clear
Clear: the code is easy to read and easy to understand and maintain.
- Simple logic
- Brief code line
- Function briefs
- Comments (or self-comments)
- Clear hierarchy
4.1 heavy code Header
Example: Multi-Level struct Variable Search
<Span style = "font-size: 14px;"> A1 = A-> B-> C. d. a1; b1 = A-> B-> C. d. b1; C1 = A-> B-> C. d. c1; D1 = A-> B-> C. d. d1; </span>
Assume that A, B, C, and D are long strings, such as A1, B1, C1, and D1. If there are many variables, the code looks very heavy. It is inconvenient to start writing and read.
Code modification:
D = A-> B-> c.d; a1 = D. A1; b1 = D. B1; C1 = D. C1;
4.2 function briefs
- The number of function lines is recommended to be less than 200.
- Complex functions are written into several independent subfunctions to ensure that the logic of the trunk is clear.
4.3 Module clear diagram (1) Unclear hierarchy
Figure (2) Clear layers.