Directory: 1, Abstract Factory --- Abstract Factory 2, Builder --- Builder 3, Factory Method --- Factory Method 4, Prototype --- Prototype 5, Singleton --- Single Piece 6, Factory Method --- Factory Method 7, Adapter ---- Adapter 8, Composite --- Combination Mode 9, Decrator --- Decoration 10, Façade --- Appearance 11, Flyweight --- Enjoyment 12, Behavior 13, Command --- - Command 14, Interpreter --- Interpreter 15, Iterator --- Iterator 16, Mediator --- Intermediar 17, MEMENTO? Memo 18, OBServer --- Observer 19, State --- State 20, Strategy- - Policy Mode 21, Template Method --- Template Method 22, Visitor ---- Accessor Mode Creation Mode Abstract Factory --- Abstract Factory Definition: Provide a series of interfaces that create a series of related or interdependent objects without Specifies their specific class usage frequency: Use Scenario: Happyfather and Happermother quarrel, happyfather go home to find "Do housework" on a note on the table, so HappyFather starts to wipe floor, brush the toilet, clean up the room, cook, foot After a few hours, I finally understood the hardships of Happymother's hard work: "Do housework" is equivalent to the abstract factory, and HappyFather makes a series of related households. Other applications: in the system or class library of multiple products Simply call the abstract factory to create a sub-part that needs to be implemented
Builder - Generator Definition: Separate a complex object to his representation, making the same build process can create different representations. Using frequency: Using Scenario: Happymother is very strange why happyfather can make clothes, sweat, blood stains, so dirty clothes should be washed first, then they can put them together in the washing machine: A complex object Each component is created separately, a part of the process of washing and part of the hand wash (complex part) for the washing, and the difference between the abstract factory is that it will only return to an object, and the abstract factory returns a series of related objects.
Factory method --- Factory method definition: Define an interface for creating an object, let the subclasses decide which class, Factory Method makes a class instantiated to the subclass usage frequency: Used: 1 month The day is the days of Happy family celebration, because this day is a day of happyfather's salary. Happyfather: "You do the rice today" happymother: "The meat is more incense, the son is the 50 yuan money!" Happyfather: "Remember to go online online, the place in the place" Scenario] HAPPYMOTHER gives Happy Money to Happyson as for flowers, buy something is determined by Happyson.
Prototype - Prototype Definition: Use prototype instance to create the type of object, and create new objects to create new objects by copying these prototypes: Use Scenario: Happymother: "Every day, buy vegetables, wash, cooking, I am bored no matter I did "happyfather:" The wife recently started to supply vegetable platter. Various vegetables have been matched. I will buy a plate of three fresh, a fish scent, buy it back, it is very convenient. " Happymother: "I like it!" Scenario explanation: Various vegetables platter is the prototype of cooking, stir fry, you can eat the application point: prototype clone itself, create a new object Singleton - single-only definition: Guaranteed only one class only one Example, and provide an access to his global access point usage frequency: use: happyfather: "The son does not give this to play!" Happyson: "What is Dad?" HAPPYFATHER: "This is the household account book. I started only my account page, and later added your mother's account page, and later added your account page, and later added your son, the son's grandson, the child's grandchildren ... "Scenario explanation: The whole family has only one account book, access it to other applications by increasing the household page: counter, shopping cart
Structural mode Adapter ---- Adapter definition: Convert a class interface into another interface that customers want, the Adapter mode allows you to work together because of those classes that are not compatible and cannot work together. Using frequency: Using Scenario: Time: HAPPYMOTHER during 1960: "His dad, child is going to school, but there is no such thing as a thing" happyfather: "Is there any way! Rice is not enough Money to buy clothes, or you change my clothes! "Happymother:" Good idea! ", This happyfather's clothes were changed to the HAPPYSON's clothes: Happymother cropped into HAPPYSON's new Clothes for clothes Apply Points: Adapter is suitable for existing classes, but the interface does not match.
Bridge - bridge definition: Separate the abstraction section with its implementation part, so that they can use the frequency: Using Scenario: Happy: Mother: "You said that you are responsible for sweeping the room but just sweeping, you said you cooking Calling takeaway, you said that you will take a lot of noisgers every morning "Happyfather:" You also know that I always say a set of do a set "Scenario:" Say "is an abstract part and" do "phase separation application Important points: abstraction and implementation parts are placed in separate class hierarchies
Composite --- Combination mode Definition: combine objects into a tree structure to represent partial overall relationships, composite makes users with consistency use frequency for single objects and combined objects: Used: Happyson Two years old happymother tells HappyFather: " If you don't sleep, you can sing him, you can also sway him, you can sway it while singing "happy", "Happy:" I don't want my father to swear, with the mountain car. "
Scenario explanation: There are many ways to sleep, and you can use several methods to use, all methods can be used to treat application points: the combined part can be called like a single object, such as traverse the tree structure. Decrator - Decorative definition: Dynamic gives an additional additional responsibility, in addition to the function, Decorator mode is more flexible to use more flexible frequency: Used: Time: 2003 HAPPYFATHER: " Wife, how do you embroidered on my mask? "Happymother:" Such a mask can not only prevent viruses, "HappyFather:" Can I embroidery to 'don't kiss me' "Happymother:" Remind the car driver not to hit To you, "Scenario] Add additional functionality to masks: embed the object instead of using the inheritance mechanism Façade - the appearance definition: Provide a consistent interface for a set of interfaces in the subsystem, Fa? ADE provides A high-level interface, this interface makes the subsystem easier to use frequencies: Use Scenario: Because HappyFather and Happyson indulgent eat two fat piers, Happymother will lock the refrigerator in a room, and the grandfather can only eat through Happymother. Various snacks. However, Happymother is responsible for errands, and the grandfather is not comfortable. Scenario explanation: Happymother is similar to HAPPY father and son takes snacks interface, Happy father and child only need to tell her to apply the need: reduce the coupling of client programs and subsystems FLYWEIGHT? Enjoy the frequency: Use Scenario: Happyfather: "Wife Flyweight mode example "Happymother:" Husband What is Flyweight mode "HappyFather:" is to effectively support a lot of fine-grained objects "Happymother:" Isn't calculated? Can be used for tea, coffee When you fight, you can do a hidden device "Happyfather:" ... "mode Explanation: Cups as shared objects, can be used in different scenarios, only according to its external state, Application points: Separate the internal and external state of the object, apply to different scenes according to different external states to achieve shared objects
Proxy --- Agency definition: Provide a proxy for other objects to control access to this object: Using Scenario: HAPPYSON School President's Office Principal: "You have to teach your son, he fights in school and classmates "Happyfather:" The little child is playing is very normal. "President:" It is normal to fight my son "Happy Father:"! Sorry, go home, I must have a good lesson. He "happyfather went home after the lesson" "I told you to remember, the next time I don't want to fight the son" Scenario] HAPPYFATHER is the adult guardian of Happyson is the agent application point: Proxy only provides access to the entity, Entity definitions of key features.
Behavioral mode: chain of responsibility --- Responsible Chain Definition: Make multiple objects to handle requests, thereby avoiding the coupling relationship between requesting senders and recipients: Using Scenario: Happyson: "Mom Will not help me "happymother:" To first then then this is this "happyson:" Mom will not "happymother:" I will not, ask your father to go, "happyfather:" happyfather: " So simple, you both watched TV, I finished calling you "Scenario: Happyfathe and Happymother have the duties of the counseling Happyson homework, who will help to handle the application point: requesting no clear recipient, through the successor chain Perform the transfer request command ---- Command Definition: Package a request to an object, so that you can use different requests to parameterize the customer, queuing and logging the request log, and supports the revocable operation usage frequency: Using Scenario: "Happyfather:" KFC? I want a big bottle Coke, my wife wants a bottle Coke, my son wants a small bottle to take a taking a bucket "Hai HAPPYFATHER:" I don't want this big bottle "KFC Self-owner: "Sorry for sir, you have to pay" happyfather: "," HAPPYFATHER: "But the Command mode supports can be revoked." KFC sent the goods: "Sorry, I am just a" Scenario explained: Fast meals Command mode, everyone has different request applications: Command declaration execution operation
Interpreter --- Interpreter Definition: Give a language, define a representation of his grammar, and define an interpreter, this interpreter uses this representation to explain the sentence usage frequency in the language: Use Scenario: 19 × × year Day, Happyson nine months old happyss: "Wow ... wow" happymother: "Hipmond" happyss: "Wow ..." Happymother: "Husband, quick milk powder, son hungry" happyss: "嘻 .................................................................... .. Sentence
Iterator --- iterator definition: Provides a method sequence to access the individual elements of a aggregated object, and do not need to expose the internal representation of the object: Use Scenario: Happyfather: "Fast Broadcast, Joan kiln series of dopelessness" Happyfather: "Fast broadcast, Chinese football is more than my feet" happyfather: "Skip the central nine, all the birds don't understand" happyfather: "Look this, eye-catching" Happymother burst K happyfather happyfather: "Don't face the face, I will go to the street tomorrow!" The original happyfather wants to see the model contest explanation: All TV station is a collection of sequential access to the list of applications: Access to the list and traversal from the list object Separate and put it into the iterator object Mediator --- Mediator definition: Package some columns in a multi-column interactive frequency: Using Scenario: Work Monitoring Relationship, Happy Moves to ×× City, because ×× City The people are particularly difficult to get along with, so HappyFather is rented through the house intermediary: rent funds, supporting facilities need to be negotiated with the intermediary, then negotiate with the landlord, so that the direct contact with the landlord is avoided: Intermediary Enter the role of the intermediary: Package the interactive operation between the objects to the Mediator intermediary object
MEMENTO? Memo Definition: Under the premise of the object, capture an internal state of an object and save this status frequency outside of the object: Use Scenario: Happymother: "If you have a date you! Not let you go to the toilet I actually dared to watch TV! "Happyfather:" Today is our marriage commemoration, I am watching the marriage video "happymother:" If you have a conscience, remember this day "Scenario explanation: Marry video is a memo application point: record object In an instantaneous internal state to support the cancel operation mechanism
Observer --- Observer Definition: Define a pair of dependencies between objects. When an object is changed, all objects that depend on its objects are notified to automatically update usage frequencies: Use Scenario: United States offensive Iraq, Happyfather Every day Reading the latest news, Happymother watches TV every day, Happyson browsing the latest news, the battle changes, a family change, a person through different objects: Newspapers, TV, network news is dependent on Iraq battle Other applications: When data changes, the table is used for data display, and the figure follows the change.
State --- Status Definition: Allows objects to change his behavior when its internal state changes. Objects seem to change his class usage frequency: use: HappyMother: "Husband, get up and take medicine" happymother: "Husband, get up to eat some fruit" happymother :: "husband, don't make a job , Go to rest "嘿, this is so comfortable, happyfather is going to bed on the bed. Happymoterh:" How can you still pack the room? "Happyfather:" I ... I have not good "happymother:" Happymother: " Dead! "Happyfather:" It is not sick to have a difference! "Scenario explanation: Disease and disease are two different state applications: put all the behaviors related to a specific state in one object Strategy --- Policy Mode Definition: Define a series of algorithms to encaps them, and enable them to replace each other, this mode allows algorithms to use their customers independently: Use Scenario: Xiao Wang two years ago It is not still still returned to the money of HAPPYFATHER, just a good opportunity to be a guest this day (it is a good opportunity for the account). First, I will knock on the side of the Side-squeezing method: "I saw our old classmates in the first two days. He also borrowed 1,000 yuan, saying that it was borrowed two years ago, he or not, I have forgotten" Xiao Wang: "Yes, Xiao Li's memory is good, and it is much better than me." I didn't work, the next trick, the snake, the hole, HAPPYFATHER: "I heard that you have recently a good business, how is the cost? Also? "Xiao Wang:" It's almost a red fire, and the debt is basically clear. "It seems that you can only go straight into Happyfather:" Then you borrow my 2000 yuan should also be! "Scenario explanation: Wang Ji account, HAPPYFATHER has three methods, and the methods can be replaced with each other, and these methods have a role. Application points: different algorithms with different categories instead of the algorithm directly encoded to the code
Template Method - Template Method Definition: Define the skeleton of the algorithm in an operation, and delay some steps into subclasses, TemplateMethod allows subclasses to redefine certain specific specifications of the algorithm step. Using frequency: Using Scenario: HAPPYMOTHER handed HappyFather a sweater braided teaching book: "Choose you you like the style, I am cold, I give you a sweater" happyfather: "You? Weaving? I didn't listen to the wrong!" Happymother: "What is this book, the fence, I will also weave!" Scenario explanation: Sweater woven teaching book is quite a template, happymother can weave the above-like sweater other applications: Template can be used as The abstraction of the core business, the customer layer is implemented in different business, achieving the purpose of multiplex core business