The primary technical mission of software is management complexity. Why?
Complexity:
You have had such experience: At the same time, you will surely lose nothing!
Although you are very busy, the results are not satisfactory.
Or one thing, but there are too many things that you always want to do at a time. Here we also do it. The results are messy and you can try again ......
Human Brain has limited processing capabilities and cannot focus too much on things at the same time. Too many things will lead to some omissions and confusion;
It's like playing a juggling game: The two balls that are left in the air are relatively easy to control, and the complexity of the two or more balls increases greatly;
InCodeDuring the design process, if you focus too much on it, the more complicated it will be, the more complicated it will inevitably lead to omissions and errors.
Too many things or logics need to be followed at the same time are not advisable, but there are many logic and complicated things in the software.
To ensure the performance of all aspects of the Code, management complexity becomes very important!
How to manage complexity in software:
LMinimizes the amount of essential complexity that anyone needs to deal with at the same time;
LDo not let unexpected complexity grow at a rate without fear;
Some principles to be followed in code design to help manage complexity:
Minimum complexity: allows you to focus onProgramAnd ignore other parts with peace of mind.
There are many design principles for reducing dependencies between systems: Inter-module dependencies, platform dependencies, and so on. The principles currently come into use and are actually applied:
Streamlining: The code should be as logically clear and structured as possible to eliminate useless code. For example, a function is a logic, and a class has a single function;
Hierarchy: Hierarchical design of the system, access interaction by hierarchy, and unified abstraction of the dependent parts to provide consistent interfaces.
The lower layer feels "simple and beautiful" to the upper layer. Just like the iPhone, it looks beautiful and simple. It encapsulates complicated things.
Loose coupling: Minimize the associativity between programs, abstract encapsulation and information hiding between modules and classes;
In order to reduce the association between them, the interaction mode is simple and simple.
Reduce dependency: System dependency and external module dependency. No dependency is impossible. We can only reduce dependencies and encapsulate the dependencies.
Reduces the changes caused by excessive dependencies when the system or module changes.
And so on.