In the past few days, the teacher told us about the design model. Let us re-baptism from the learning methods and understanding of various models. Here, I sorted out my notes and my feelings.
I. Structural
The structure mode processes the relationship between classes and classes, or between objects and objects.
1. Appearance mode-Facade
(1) This mode defines a high-level interface to make subclass easier to use and provides a unified interface.
(2) Advantages:
Separating users from Subsystems reduces their coupling, facilitates system maintenance, and provides better scalability.
(3) Principles:
Conforms to the Demeter law and violates the open and closed principle.
2. Bridge Mode-Bridge
, We can see the main architecture of the bridge mode. It abstracts from two dimensions, and then connects the two abstractions with an association (aggregation) Relationship to form what we call a bridge.
(1) Bridge pattern: separates abstract parts from their implementations so that they can all change independently. It is an object structure mode, also known as the handle and body mode or interface mode.
Example of writing a brush,
(2) Advantages:
The Bridge Mode separates the changes of the two independent dimensions to reduce coupling.
Avoid Multi-Level inheritance and reduce the number of child classes.
Easy to expand.
(3) Principles:
It complies with the principle of open/closed, dependency reversal, and merging/aggregation reuse.
3. Proxy mode-proxy
(1) when it is difficult to access an object, the proxy mode can use an object proxy to access another object, so as to complete some functions.
(2) Advantages:
Reduces system coupling, enhances scalability, improves system performance, and improves operation efficiency
(3) Principle
In line with the principle of open and closed, the Demeter Law