FlexibleService |
|
Behavioral |
Intent
Decouple a behavior from an ancestor class so that the descendant classes
dynamically specify a specific behavior.
Solution
- Use the Objectifier pattern to provide a class hierarchy of easily
variable services packaged in object classes.
- Apply the Template Method pattern to define methods in the
AbstractClient which request a ConcreteSubject reference by calling
GetService().
- Override GetService() in ConcreteClient and return ConcreteService.
Consequences
- Results in extremely flexible and extensible framework designs.
- ConcreteClients completely control the specific service used and may
change service objects on the fly as needed.
- Adds additional overhead since each service call is preceded by a
call-back to GetService().
Related Patterns
OO Workshop
The NASA / Korson-McGregor Object-Oriented Design
Workshop, David Van Camp, Goddard Spaceflight Center (offsite),
NASA, Lanham, MD, 1997—1998.