A background application
observer mode, also known as Publish / Subscribe ( Publish / the Subscribe ) model, we can understand: only concerned to receive information letter public concern No.
II. Advantages and disadvantages
Advantages:
1, can dynamically change an object's behavior
Disadvantages:
1, the client must know all the policy class, and to decide which strategy to use class
2, the Strategy pattern will result in generating a lot Strategy
III. Composition
1. Operating Environment category: Strategy
This strategy mode environment, in fact, is where the use of
2. Class scenarios: Person
This is the type of client access, that is, objects of this class held policy
3 specific policy class: Car
Specific implementation strategy class
4 .. abstract strategy class: CarFunction
According to different needs, different strategies to produce the interface or algorithm
IV. Code implementation