Design Patterns and soccer (c)

     Behavioral patterns (on)

     (13) Chain of Responsibility pattern :Buffon throw a ball to Chiellini, Pirlo, Chiellini passed the ball straight to the quick plug Pirlo after Balotelli dribbles, Barlow Terry barbed shot the ball into the ball into, but also Balotelli,Balotellimeritorious service, great Italian striker! He succeeded in the glorious traditions of Italy, Baggio, Inzaghi, Del Piero at this moment their souls! Balotelli behalf of the Italian football history and tradition, at this moment he is not a man in battle, he is not a man!laughing out loud

      Here, football is a request, and the request is processed by the players, football continues to be passed between players, constitute a transfer chain.

      Duty chain (Chain of Responsibility): between a sender and a receiver coupled to the release request, the plurality of object a chance to handle the request; these objects will be connected into a chain, transfer along the chain and the requests until an object handles it.

 

     (14) command mode : Prandelli palm outward, a forward push, full line pressure on Italy; prandelli palm inwardly, rearwardly wave, Italy back against the line. As Italy coach, Cesare Prandelli is the sender of this command, gesture command object is the recipient of all the players are commands. Different commands corresponding to various objects to perform the action.

      Mode command (Command): Encapsulate a request for an object, thereby to client requests using different parameterization; request queue or log requests, and support the operation of the cancel.

 

      (15) Interpreter mode : In football, the coach is a language of gesture, some said, "pass", and some said that "the pressure across the board," some means "defense line", each player needs reading coach in the game gestures and convert them to execute instructions, according to the coach's intention to expand the offensive and defensive.

      Interpreter pattern (Interpreter): language grammar defines and establishes an interpreter to interpret the language of the sentence.

 

      (16) iterator pattern : The following appearance of the Spanish team: No. 1 goalkeeper Iker Casillas, defender Pique No. 3, No. 6 Yineisita midfielder, Xavi No. 8, No. 9 Torres .... .. one by one to, do not worry, this is in accordance with the jersey number, next time in accordance with the position from front to back, left to right once introduced. Spain is an aggregate object contains multiple players can provide an iterator to traverse one of the players.

      Iterative mode (Iterator): to provide a method for accessing a sequential polymerization of the respective object elements, without exposing the interior of the object representation.

 

       (17) intermediary model : how do fall race? Look referee; not top of the ball how to do? Look referee; kicked the vital parts is how to do? Look referee; the ball in the end did not enter into, look at the referee! . The referee is often the protagonist football stadium, when the two players clashed, the referee is still very important to drop, he served as a mediator (mediator) between the players. All need to obey the referee, he is the boss stadium!

      Intermediary model (Mediator): with a mediation object that encapsulates set of objects interact; Mediator keeping objects explicitly referring to each other, so that it loosely coupled, and can be changed independently of the interaction between them.

    Behavioral patterns (lower)

   Italy last night too with a cup! ! ! Do not say, continue to the last part finished.

    (18 ) memo mode: the ball is round, anything is possible. If there is regret, then, if we can return to midfield last night, the 2012 European Cup final rest, I will not believe Prandelli replaced Montolivo with Motta; if they can return to the beginning of the game last night, I I believe the beginning will not let Chiellini play, if you can back ...... (may return to Italy was eliminated Germany, smile) can return it? Not return Oh, if you could go back, then I really would like to once 20 years old (memories of her green years), but unfortunately life does not regret ah. Fortunately, the software system in the state of the object can be achieved through recovery mode memorandum, the memorandum is the software of regret, it is the software of the fight. Ctrl + Z, the revocation with you!

      Memo mode (Memento): without violating encapsulation, capture and the internal state of an object, and save the state of the object outside, so that after the object can be restored to the previously saved state.

 

     (19) the observer pattern: the coach waved his hand, pressed on across the board. In this case, the coach is to observe the target, players are observers, many have linkage between observation and objective observer, of course, the referee can also be seen as players observe the target, a blow the final whistle, the Spanish music into one, crying Italy into one, different observers reacted really different,laughing out loud.

      Observer pattern (Observer): definition of the dependencies between the subject an-many, so that when a state of the object changes, all objects that depend on it have been notified and updated automatically.

 

     (20) Status Mode: play football is to look at the state, of course, the state will be converted. Some players play when the state can not, always "think about life", this time in a "sleepwalking"; kicked kicked status got better, Toudingjiaoti, lucky you may even score, this time in a "state of excitement "; then as the physical decline, action deformation, shot Ruanmian weakness, touched on the back, but this time in a" state of exhaustion. " As the game progresses, these state transition occurs, and in different states of the player's behavior is different, basically no shot at a sleepwalking state, in a state of excitement basically did not pass (full shot himself), in the state essentially no burnout steals (Nabu Wen himself, and also grab what to grab). If each state is encapsulated in a state class, then the player is to have the state of the environment category.

       Mode state (State): allows an object to change its behavior when its internal state is changed, the object will appear to change the class to which it belongs.

 

     (21) Strategy Mode: It is said that when the beginning of the 1863 football popular 1-0-9 formation, a guard, nine forwards, wood offsideSurprise. With the development of football, the formation of modern football more and more change the face of defensive team, you can choose 3-5-3 formation, face strong offensive team, you can select the 5-4-1 formation, of course, the classic 4-4-2. Each formation is a strategy to face different opponents may choose different strategies.

      Strategy pattern (Strategy): defining a series of algorithms, encapsulate them one by one, and makes them interchangeable, so that the mode change policy algorithm may be independent clients that use it.

 

     (22) Template Method pattern: " !. This corner of Italy is an opportunity, not much Spain face Italy comprehensive approach today dominant, positioning the ball is perhaps the most effective way to break the Pirlo a tactical corner, passed Cassano, Cassano before the transfer point, Marchisio header Qiangdian, dome high. but this corner with a very sophisticated design, poses a threat to Spain, but the whole game is not such opportunities multi-ah !!. " In tactical corner, A is kickoff, B pass, then C Qiangdian shot, which is a tactical frame, of course, the point C in the end is a front or grab the grab points can be selected according to the actual situation, if the design of the tactical corner kick as a template method, then each step is a basic method in which to invoke, but also in the different tactics in the implementation of certain concrete steps also vary. Perfect! Really atypical application template method pattern!

      Method pattern template (Template Method): The definition of a skeleton algorithm operation, some steps to subclasses delay, so that subclasses can not change the structure of an algorithm of certain steps of the algorithm to redefine.

 

      (23) visitor pattern: some people engaged in a football match like the data. Some specialize in running away from a game each player, each player's number of research and some steals, some studies each player's number of shots, the number of passes and some research players, some players pass study ...... If the success rate of each type of research as a visitor, then the team is a team more object structure containing the elements to study for different visitors smile, of course, we can also very easily add new visitors (researchers), for example, studies of the number of times each player spat in the game, study the number of each player in the game "close contact" with the other players ......

      Visitor pattern (Visitor): represents the operations of the respective elements of an object structure, the effect may not change the definition of the class under the premise of each element in the new operation of these elements.

 

      Because ignorant, Tongueexplaining part of the design pattern was somewhat far-fetched, for your entertainment gossip entertainment, please accept my gift!smile

Published 25 original articles · won praise 1 · views 786

Guess you like

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