seminar sse, ustc Topic 8 Observer, Mediator, Facade

Group K 1. The (, chapter 16 and 17) 1) the observer is an interface or abstract class defining the operations to be used to update itself 2) a solution to these problems A. Decouple change and related responses so that such dependencies can be added or removed freely and dynamically 3) solution A. Observable defines the operations for attaching, de-attaching and notifying observers B. Observer defines the operations to update itself 4) liabilities A. Unwanted concurrent update to a concrete observable may occur

Figure 1 Sample Observer Pattern

2. The (Behavioral pattern, chapter 16 and 17) 1) the mediator encapsulates how a set of objects interact and keeps objects from referring to each other explicitly 2) a solution to these problems A. a set of objects communicate in well-defined but complex ways. The resulting interdependencies are unstructured and difficult to understand B. reusing an object is difficult because it refers to and communicates with many other objects C. a behavior that's distributed between several classes should be customizable without a lot of subclassing 3) solution A. Mediator defines an interface for communicating with Colleague objects, knows the colleague classes and keep a reference to the colleague objects, and implements the communication and transfer the messages between the colleague classes

1 Software design pattern seminar sse, ustc

B. Colleague classes keep a reference to its Mediator object, and communicates with the Mediator whenever it would have otherwise communicated with another Colleague 4) liabilities A. Mediator object becomes too complex

Figure 2 Sample Mediator Pattern

3. The facade pattern (, chapter 16 and 17) 1) the facade is an object that provides a simplified interface to a larger body of code or complex subsystem 2) a solution to these problems A. client wants to Use a system, but it is very complex or difficult to understand because the system has a large number of interdependent classes or its source code is unavailable 3) solution A. Facade defines an easier or simpler interface to the complex subsystem B. Client uses facade object to access resources of the complex subsystem 4) liabilities A. Adding or removing subsystems may lead to modification to facade class

Figure 3 Sample Facade Pattern

2