The 4 characters of the clean code should have:
If there only just one concept to be remembered, it should be this one.
If the program can be controlled by you, the author of the code or other who involved, this program will be a good program.
For a controllable program, which is the program can be easily understood, changed, adding new features, and easy to debug.
The more code involved, the more uncontrollable. It will become the "Gordian Knot" .
Comprehensible:Every program we write have two group of audiences;
First is the machine, compiler, syntax checker, …., they will transfer our programs to executable;
Second is us, human being; The program should be readable so that we could understand and work on it.
There are many chances that our programs will be read by someone else or yourself later.
Therefore it is important to make the code comprehensible.
Convenient:While making a large program, we may involve a lots of code. Therefore, we need to arrange the code so that it helps to do thing fast.
Here some examples:
- Find the libraries and functions available in the project and how to use it
- Quickly navigate to the class or method we want to go.
- Easy to remember the classes involved
To do so, we need to adopt a good naming contention and code style.
ConsistentAs we know, many words in English can refer to a similar meaning; One frequent met example in coding: number of X, count of X, size of X; In order to prevent our code audience getting confused or mislead, we need to make sure the same word have the same meaning;
If you use "count" as the suffix telling how many, keep to use it over your class.