Reading Notes, Reading Notes
The design pattern allows you to share words with other developers. The design pattern can increase the level of your thinking architecture to the pattern level, rather than staying on trivial objects.
Design principles:
- Encapsulate changes: Identify potential changes in the application and separate them from those that do not need to be changed.
- Multi-Purpose Combination and less inheritance: users can build systems with great flexibility. They can not only encapsulate the algorithm family into classes, but also dynamically change behavior during runtime, as long as the combined behavior object meets the correct interface standards.
- For interface programming, it is not for implementation programming: The interface mentioned here is not just for the interface, but for the super type, it can be understood as "for the super type programming ", the key to this is polymorphism.
The policy mode defines the algorithm family and encapsulates them separately so that they can be replaced with each other. This mode makes the algorithm changes independent of the customers who use the algorithm.
The observer mode defines one-to-multiple dependencies between objects. In this way, when an object changes its state, all its dependent persons will receive notifications and update them automatically.