Before the bigger plan, I will first take the lessons of Design Pattern. I saw the style of Decorator in "Head First Design Patterns" and found that the Jolt Award is not white, the narrative ability, the expression is clear, not the old husband that is full of abdomen. And the entire Pattern's story process is gradually entered, it can be guaranteed - Xiaobai can learn the design model. If there is a Chinese version, you must buy a copy, the next generation of programmers are blessed. Unfortunately there is a style. The HEAD FIRST series is not easy to find, I have to turn out the books of the old gentlemen. This Temple is completely completed, in fact, GOF80% model is based on one principle:
Prioritize the object combination, not the class inheritance.
People who begin to learn OO are used to going to map the world with the real world, inheriting is the most natural idea. GOF is actually to reverse this idea, let everyone use the combination, commission and program objects. The combined mechanism can vary vast majority of GOF mode as long as the two principles can vary. 1. Any coupling can decouple representative modes by adding an intermediate layer: Facade, Mediator, Adapter, and Factory / Abstract Factory, Proxy 2 By combining the object characteristics, you can avoid pure inheritance of the class explosion representative models: Bridge, Decorator, CHAIN of Response, Strategy / Command
3. There are also some independent common patterns such as Singleton, Visitor, Observe
Write to yourself and play slow mirror: 1.Facade: In order to reduce the coupling between a system and the internal class of another system. Establish the main function of the target A agent system
2. Mediator: In order to reduce the coupling between the two objects. Create an intermediate object C and have an example of A and B, and assign C to A and B
3.Adapter: In order to match different objects to use the same interface. Establish a method of object B, proxy A and match their interface.
4.Factory: In order not to rely on the specific object, it relies on the creation of the interface. The program gains objects through Factory.
5.Proxy: In addition to not depending on the specific object, you can insert actions during the process. Method for calling objects by Proxy (AOP)
6.Bridge: If the object is developed to both directions, Bridge can avoid the arranging combination of two groups of object features causes classes explosion. A set of features such as large cups, medium cups, a set of features such as adding milk, add sugar. The abstraction of one of the features is separated into interface 2, and the instance of the interface 2 is introduced into the main inheritance tree.
7.Decorator: Add new actions to the original object of the original object. The new class is inherited in the original class. When there is a principal classification and the original entity to call the new class, the original method of the original entity will be called, and the new class is added to the expansion.
8.cor: By schedule your duties, you have added your own actions according to the situation. Each object has a pointer to the next object. After completing its own operation, the control is passed to the next bit. APAHCE JARKARTA COMMANDS has a Chains library.
9.Strategy / Command: Template mode The object is combined with the action package.
10.Observe: Monitor the status of the OBserveBal object through a set of mechanisms. JDK implements two sets of interfaces to assist.
11.Visitor: Through a set of mechanisms, let all objects in the combination, perform a common action. The visited object has an Accept (Accessor) function, calls the visitor in the function. Access (this), is not a very elegant model.