12. Mediator Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling by keeping objects from referring to each other explicitly, and it lets you vary their interaction independently. Example: Insurance policies must be approved before they are issued. There is a procedure (which can change over time, and which is different for different kinds of policies) for approving a policy. This procedure must interact with work queues of managers and with the history that is kept on the customer. Instead of putting this procedure in the insurance policy, put it in a separate object that is easy to change. (This is a “business process”)
14. Mediator Procedure CustomerHistory InsurancePolicy Worker Mediator Colleagues If interaction is main thing that changes, then make the interaction be an object. Colleague classes become more reusable. Mediator is the non-reusable part.
38. Managing dependences Application2 Subsystem2 Subsystem1 Application1 Suppose Application2 depends on only a small part of Subsystem1, and that part doesn’t depend on Subsystem2