Design Patterns and football (two)

      Structural model

      (6) Adapter pattern :a lot of football coaches like to invite foreign (including one we are very familiar with the national team, even the name is not to say, we know everything,smile), please come back often difficult foreign coach with the players directly AC (language barrier), it is necessary with translation, this time, the adapter acts as a translator between coaches and players, is responsible for coordinating communication between coaches and players.

       For example: pass -> shoot -> goal conversion pass -> shot -> Goal  

      Adapter mode (Adapter): to convert the interface of a class into another interface desired by the user, so that those classes otherwise because of incompatible interfaces can not work together with the work.

 

      (7) bridge mode : in football, was playing forward, it was a midfielder (midfielder, defender), it was kicked back; of course, it was left to kick the habit, the habit was kicked to the right, it was like standing in the middle, so born defender left, right, forward, center-back, right-back and other terms, is the combination of these two changes is not the dimensions of it?

       Bridge mode (Bridge): an abstraction implemented with partial separation, so that they can be independently varied.

 

      (8) combined mode : the 2012 European Cup total is divided into four groups, each group of four teams, each team has 23 players, if you use a diagram to represent all the players and national grouping of the 2012 European Cup, Needless to say, must be a tree diagram, the group has a team, the team was, if you want to convene the group B (before recognized the group of death)members of the General Assembly, wrote to inform on the node group B: "15:00 , an important meeting, a matter of qualifying! ", presumably the Netherlands, Germany, Portugal, Denmark players will respond positively, with the call these" hard to force "team on the same node branch do?smile

     Combined mode (Composite): combining objects in a tree structure to represent "part - whole" hierarchy, which allows the customer to use a single consistent objects and composite objects.

 

      (9) Decorative pattern : Now serving ads on football more and more, the 2012 European Cup one of the favorites (pre-match prediction) of the German team jersey on the right chest a Mercedes-Benz, a left Adidas, of course, can also continue to increase , neither the change of use and advertising performance jersey, but also play a decorative effect, increase revenue, why not do it? Semi-final it is not able to make the bar of God continues to "think about life," sad reminder of the German team! Add a new ad, just the original decoration can continue serving the ball.

      Decorative patterns (Decorator): dynamically added to an object some additional responsibilities, extending functionality, it is more flexible than a way to generate subclasses.

 

      (10) Aspect Mode : To reporters and the team (players, coaches, etc.) to provide a platform for the exchange, the European Cup Organizing Committee before and after every football match arranged a press conference, reporters can be a press conference with the team conducted communication (although not every player will appear at a news conference ), in this press conference served as a reporter (client) and the players, the appearance of the roles between the coach (subsystems). Of course, the press conference will not affect a separate interview with a reporter a player (which is also consistent with the definition of the appearance of classsmile).

      Appearance Model (Facade): a set of subsystem interface provides a consistent interface to define a high-level interface that makes the subsystem easier to use.


      (11) Flyweight : with a national team, they are sharing with a great title, namely "XXX national team," such as "the Italian national team," "the Spanish national team" (The question of " Chinese national team players "on the sad, or do not say,Sorry), therefore," XXX national team "is an internal state that can be shared. But in the course of the game, each player wearing a different jersey number, jersey number can not be shared, with a national team everyone has different numbers, therefore, are not able to share the jersey number of external state. It distinguishes the internal state and external state of an object in Flyweight mode.

      Flyweight (Flyweight): Use sharing to support large numbers of fine-grained objects.

 

      (12) Acting mode : soccer court, player transfers is a hot topic. Transfers of course, can not do without the player's agent, broker will deliver players the idea to another club. Broker is the agent of the player, the player is a target object, a proxy object broker, broker isolate the players and the "client", "commercials, please find my agent," "interview, please find my broker people"......

      Agent mode (Proxy): a proxy to control access to the object to other objects.

Published 25 original articles · won praise 1 · views 787

Guess you like

Origin blog.csdn.net/qq_42770949/article/details/104321985