"The Way of Concise Code" reading notes

1. Be clear, concise and professional

Goal: It has very good maintainability, so that maintainers/walk-through people can easily understand the code like reading a story.

The clarity, conciseness, and professionalism that emerge from this book are the qualities that permeate the code.

2. Naming

In a word:

The naming of each variable, function, class, field, etc. should have a clear, concise and professional self-commenting nature !

The evaluation index is: let others understand at a glance what this thing is for

3. Function

(1) The function body should be short (concise)

(2) There is only one level of abstraction, and it only does one thing (clear, professional)

(3) As few parameters as possible: reduce error probability and test cost (simple)

(4) Structured programming: single input single output. Personally disagree with this approach

4. Notes

Regarding code, the best comment is the code itself, which is self-commenting. For example, giving a good name to a variable/function is much better than writing a comment to the function header.

Necessary notes:

Legal information, intent, warning, TODO, api documentation

bad comment:

Logging (use version management instead), crap...

5. Format

Vertical distance, horizontal dislocation, there is nothing to say, aesthetic issues, just ask yourself whether the things you write are beautiful or not.

6. Make it up later

 

 

Guess you like

Origin blog.csdn.net/u012824853/article/details/114764476