OOTV Cup Super Mode contest--Model summary

Source: Internet
Author: User

The learning of design patterns is coming to an end, and these days, we have been wandering around the world of big birds and side dishes. That section of the classic dialogue, that interesting and full of knowledge of the experience, really let yourself benefit.

In addition, the OOTV Cup Super Model competition, really wonderful. So, let us as the pace of the game, once again as the audience, together to aftertaste, once again appreciate the charm of the various models.

Host--gof, first appeared at the front to greet everyone. Someone might ask, why would the host be her? In fact, the students who have studied the design pattern know that the GOF is not small. Let me first give you a brief introduction to GOF.

GOF, full name gang offour, Chinese names for four people group. "Design patterns:elements of reusable object-oriented software" (i.e., the book " Designing Mode ") by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides co-authored (addison-wesley,1995). These authors are often referred to as the "foursome" (Gang of Four), which is also known as the "foursome (or GoF)" book.

Next, Gof introduced us to the first guest to the scene, OoTV's founder, Mr. Oo. Perhaps we have not had personal contact with him, but in fact, his ideas have long been known around us. So far, he is still the person we admire most. In his body, whether it is encapsulation, inheritance or polymorphism, we need to learn well.

Below, Gof for us is the six major judges of this game. As long as the keyboard is knocked up, programmed, we all need to ask the review of the comments, to see exactly what they taste. Look, there are six of them sitting on the stage, the scene instantly serious. However, we still need to introduce them.

"Single duty, sir." He may feel more difficult to touch, so his friends are less. He pursues the principle that there should be only one cause of change in the case of a class.

"Open and closed, sir." He's like the one we used to call Bao, untouchables. He pursues the principle that software entities (classes, modules, functions, and so on) should be extensible, but not modifiable.

"Reliance on Mr. Inverted," he is a more exclusive, dead-minded. He pursues the principle that both upper and lower level modules should rely on abstraction, and detail should also be dependent on abstraction.

"The Richter substitution Lady" she was very selfless, and everything she had had to be passed on to the children without any reservation. The principle she pursues is that subtypes must be able to replace their parent types.

"Synthetic polymer multiplexing lady" She always gives us inculcate and tells us what to do and what to try not to do. She pursues the principle of using synthetic aggregations as much as possible and not using class inheritance.

"Mr. Dimitri" he's always trying to save us a little bit more. He pursues the principle that if two classes do not have to communicate directly with each other, then these two classes should not have a direct interaction. If one of the classes needs to invoke a method of another class, the call can be forwarded through a third party.

Well, with GOF announced the rules of the game: "This contest is based on the characteristics of the model, set up three categories, namely, the creation of the model, the structure of the model and behavioral mode." ... "The game begins. The first team to play was the first set of five players to create the model. They were:

Let's give them a couple of stages to enjoy their show time.

"Abstract Factory lady" There she is, it is easy to access any table in the database. Her slogan is to provide an interface that creates a series of or related dependent objects without specifying their specific classes.

"The builder Miss" with her, we can build a variety of different villains. Her slogan is to separate the construction of a complex object from its representation so that the same build process can create different representations.

"Factory method Miss" access to the data, although she is not as her sister, but she has brought us a lot of convenience. She claims to define an interface for creating objects, so that subclasses decide which class to instantiate, and the factory pattern defers the instantiation of a class to its subclasses.

"Miss Prototype" are you still upset about your resume? Prototype, she'll be able to fix it for us. Her intention was to use a prototype instance to specify the kind of object to create, and to create a new object by copying the prototypes.

"Single lady" only one of the number, but this is enough, why waste it, Singleton, she has been looking at us. One in the toolbox is enough. She advocates simplicity as beauty, guarantees that a class has only one instance, and provides a global access point to access it.

Well, we have a further understanding of the five players. From their respective slogans, it is not difficult to find out, in fact, they are arranged in the first round of the creation of the model is still a reason, simply speaking, they are in their own way to achieve the creation of their own instances. In particular, the factory method and the abstract factory two sisters are really similar, but they are different degrees of abstraction.

The second group was on the seven-player model of the structure,


Let's see what they're going to show us.

"Miss Adapter" still worried about not being able to communicate with foreigners? Yao Ming is sent out of the adapter, you do not have to out. Her slogan is to convert a class's interface into another interface that the customer wants. The adapter mode makes it possible for those classes that would otherwise not work together because of incompatible interfaces to work together.

"Bridge miss" envy other people on the Apple phone software? Don't worry, find the bridge, she let your phone also have. What she advocates is to separate the abstract from its realization, so that they can all change independently.

"Group Miss" a company, the most important is the sharing of resources, afraid of being left behind? There are combinations in which you will never be abandoned. Her slogan is to combine objects into a tree structure to represent the ' partial-whole ' hierarchy, which makes the user consistent with the use of individual objects and composite objects.

"Decoration Miss" to see the object, how to dress up? Please decorate to help, as long as you want, she can help you achieve. Her intention was to dynamically add some extra responsibilities to an object. For added functionality, she is more flexible than generating subclasses.

"Appearance miss" investment risk, everywhere need to be cautious ah, want to go home to sleep also can make money, or look for the appearance to help it, she above someone. She says that providing a consistent interface for a set of interfaces in a subsystem, the appearance pattern defines a high-level interface that makes the subsystem easier to use.

"Miss Yuan" will do the website, we all come to find. But the efficiency is low, this does not reduce effort. Ask for the Yuan Bar, she will help us solve. Her declaration of participation effectively supports a large number of fine-grained objects using shared technology.

"Deputy Miss" want to send the person you like a gift, but also embarrassed. Then find an agent, others will not expose you. She claims to provide a proxy for other objects to control access to the object.

Obviously, this group of players and the creation of the players have a different focus on the performance. From their slogan, we can more clearly see that they are in the emphasis on class and class, objects and the relationship between the object, to exert their all-out, on the one hand to alleviate their burdens, on the other hand, but also to bring more convenient and thoughtful service to you.

In the end, there were two groups of players, a total of 11 people,

Here are some of them.

"Miss Observer" is caught by the boss to watch the stock game, then you must not have a good relationship with the observer. Her slogan is to define a one-to-many dependency between objects, and when the state of an object changes, all objects that depend on it are notified and updated automatically.

"The template method miss" Exam results are low, why? The original topic are copied wrong, can be good. Next time still ask the template method to help, must be high points fly. She advocates defining an algorithmic skeleton for an operation, and delaying some steps into subclasses, so that the template method allows subclasses to redefine some specific steps of the algorithm without altering the structure of an algorithm.

"Order Miss" to eat in the restaurant feel really good, the waiter called the service is very thoughtful, call, do not worry about her more charges. She felt that a request should be encapsulated as an object, allowing you to parameterize the customer with different requests, queue up requests or log requests, and support revocable operations.

"Miss Status" every day to work, who have the ability to always be energetic. It's time to eat, sleep, work, and work. She says an object changes its behavior when its internal state changes, making the object seem to modify its class.

"Miss responsibility Chain" price rises, want to raise Ah, to who say AH. Don't worry about it, tell the chain of responsibility, she'll manage everything, you can say it. She has always believed that multiple objects have the opportunity to process requests, thus avoiding the coupling between the sender and receiver of the request. Link the objects together and pass the request along the chain until an object handles it.

"Miss Interpreter" boss to talk to you, disturbed, he is trying to praise me or fire me, really do not understand AH. Let's ask the interpreter. She claims to be given a language, defines a representation of its grammar, and defines an interpreter that uses that representation to interpret sentences in the language.

"Miss Intermediary" now life is so peaceful and stable, all rely on intermediaries to find the Security Council to help AH. If he had gone, the Third World War would not have erupted. She said she was using a mediation object to encapsulate a series of object interactions. The mediator makes the objects not need to explicitly reference each other, so that they are loosely coupled, and can independently change the interaction between them.

"Miss Visitor" you succeeded, failed, or fell in love, married, think of other people's feelings. Ask the visitor, she can tell you. She represents an operation that acts on elements in an object's structure. It allows you to define new actions that act on these elements without changing the class of each element.

"Strategy miss" shopping malls always promotion, how can I buy it cost-effective. Ask the strategy, let her help us calculate the accounts. Her intention was to define a series of algorithms, encapsulate them each, and make them interchangeable. This mode allows the algorithm to be independent of the customers who use it.

"Miss Memo" consumer music finally hit 130 off, a crash, all gone. Blame who ah, or blame oneself Bai, who lets you play the game not to find MoU together. She said that without compromising encapsulation, the internal state of an object is captured, and the state is saved outside the object. The object can then be restored to its previously saved state.

"Miss iterator" bus that crowded Ah, directly mixed in the car, who still buy tickets ah. No, the car is easy to get out of the difficult, do not buy tickets who do not go, the iterator waiting for you at the door. She says it provides a way to sequentially access individual elements in an aggregated object without exposing the object's internal representation.

So it seems that some of them can be counted as our little assistants in life. They offered us a variety of ways to prepare for our rainy future.

This kind of game, see how many times will not feel bored, not only is the feast of eyes, but also rose a lot of insight.

Tail Words:

This blog is the main design mode on the whole, for each pattern details of the things are not detailed, the details of their own things still need to accumulate in the study over and over again, which has made a special summary of certain patterns to write a blog. And before and after the study, macro-grasp two times or it is necessary to do.

OOTV Cup Super Mode contest--Model summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.