Hello, everybody, I’m here to continue what I told you last time.

Mediator mode

Four MM play mahjong, mutual who should give who how much money is not clear, fortunately at that time I beside, according to the respective chip number calculate money, earned money from me here take, lost money also pay me, everything is OK, the an got four MM of micro letter. Mediator pattern: The mediator pattern wraps the way a set of objects interact so that they don’t have to interact obviously with each other. This allows them to be loosely coupled.

When the action between some objects changes, it does not immediately affect the action between other objects. Ensure that these effects can vary independently of each other. The mediator model transforms many-to-many interactions into one-to-many interactions. The mediator pattern abstracts the behavior and collaboration of objects, separating the interaction of objects on small-scale behavior from that of other objects.

18 Memorandum Mode

At the same time with a few MM chat, must remember clearly just said some of what words with MM, otherwise MM found will not happy of oh, fortunately I have a memo, just with which MM said what words I copy a memo inside to save, so can at any time to look at the record before.

Memo pattern: A memo object is an object that is used to store a snapshot of another object’s internal state. The purpose of the memos pattern is to capture, externalize, and store the state of an object without breaking encapsulation, so that the object can be restored to the stored state at a later appropriate time.

19 Observer Mode

Would you like to know the latest MM information of our company? Just join the company’s MM intelligence email group, Tom is responsible for gathering intelligence, he finds new information, not to inform us one by one, directly to the email group, we as subscribers (observers) can receive the intelligence timely.

Observer pattern: The observer pattern defines a multi-group dependency that allows multiple observer objects to listen to a subject object simultaneously. When the topic object changes in state, all observer objects are notified, enabling them to automatically update themselves.

20 State Modes

With MM contacts, must pay attention to her state oh, in different states when her behavior will be different, such as you ask her to go to a movie tonight, you have no interest in the MM will say “something”, you do not hate but have not liked the MM will say “good, but can bring my colleague?” “The woman who already likes you will say” What time? How about going clubbing after the movie?” Of course, you see the movie process in the performance of good words, also can turn the MM’s state never hate do not like into like oh.

State mode: State mode allows an object to change its behavior as its internal state changes. This object looks as if it has changed its class. The state pattern wraps the behavior of the object under study in different state objects, each of which belongs to a subclass of an abstract state class.

The purpose of a state pattern is to make an object’s behavior change as its internal state changes. The state pattern requires the creation of a subclass of the state class for each state that the system may acquire. When the state of the system changes, the system changes the selected subclass.

21 Policy Mode

With different types of MM date, want to use different strategies, some please the movie is better, some go to eat snacks effect is good, some go to the seaside romantic most appropriate, single purpose is to get the heart of the MM, I have a lot of MM in the chaseStrategyOh.

Policy pattern: The policy pattern takes a set of algorithms and encapsulates each algorithm into a separate class with a common interface, making them interchangeable.

The policy pattern allows the algorithm to change without affecting the client. The strategy module separates behavior from environment. The environment class is responsible for maintaining and querying the behavior class, and the various algorithms are provided in the specific policy class. Since the algorithm and the environment are independent, the environment and the client will not be affected by the algorithm change, change.

22 Template method mode

In fact, there are only a few steps to chase a girl, such as meeting, improving goodwill, deep understanding, confession, establish a relationship, and so on. But each step has its own method for different situations, which depends on your reaction.

Template method pattern: The template method pattern prepares an abstract class that implements some of its logic as concrete methods and concrete constructors, and then declares some abstract methods to force the subclass to implement the rest of the logic. Different subclasses can implement these abstract methods in different ways, and thus have different implementations of the remaining logic. Define a top-level logical framework and leave the details of the logic to the specific subclasses.

23 Visitor Mode

Valentine’s Day arrived, should send a bunch of flowers and a card to each MM, but the flower that each MM sends should aim at the characteristic of her individual, each card also should pick according to the characteristic of the individual, I a person which make clear, still look for florist boss and gift shop boss to doVisitorLet the florist choose a bunch of flowers according to the characteristics of MM, let the gift shop owner also choose a card according to the characteristics of each person, so much easier;

Visitor pattern: The purpose of the visitor pattern is to encapsulate operations imposed on some data structure element. Once these operations need to be modified, the data structure that received the operation can remain unchanged. The visitor pattern is applicable to systems where the data structure is relatively undetermined. It uncoupling the data structure and the operations acting on the structure, allowing the set of operations to evolve relatively freely. The visitor pattern makes it easy to add a new action, which is to add a new visitor class.

The visitor pattern aggregates relevant behavior into a single visitor object, rather than being scattered among node classes. When using the visitor pattern, put as much object browsing logic as possible in the visitor class, not in its subclasses. The visitor pattern can cross the hierarchy of several classes to access member classes belonging to different hierarchies.

Finally, I wish you all an early success in your studies, a satisfactory offer, rapid promotion and salary increase, and the peak of your life. If you can, please give me a triple support yo, we will see you next time