110 likes | 262 Views
Patterns – Day 8. Adapter continued Facade Reminders: Faculty candidate talk Friday 4:20 PM O-267. Brian Postow: Games and Complexity Theory No class tomorrow. Questions, comments, rebuttals, etc.? Why do Software patterns people like Christopher Alexander?. Unforseen Adaptation.
E N D
Patterns – Day 8 Adapter continued Facade Reminders: Faculty candidate talk Friday 4:20 PM O-267. Brian Postow: Games and Complexity Theory No class tomorrow.
Questions, comments, rebuttals, etc.?Why do Software patterns people like Christopher Alexander?
Unforseen Adaptation • Adaptation is easy when the client plans for it. • In Metsker’s example, we have a situation where we can redirect “standard” output to a PrintStream that is different than System.out. • What if we wish to redirect to a JTextArea? CHALLENGE 3.4You'd like to narrow the responsibility of the MessageAdapter class with a specification of the calls the client might make to it. What request should you make? CHALLENGE 3.3Write down a comment explaining what might go wrong with this approach to adaptation.
Challenges 3.5 and 3.6 • Provide an argument that MessageAdapter, as it appears in Figure 3.8, is or is not an example of ADAPTER. • Provide an argument that you are applying the ADAPTER pattern when you use the MouseAdapter class. Alternatively, argue that this is not the case.
Two-way adapter • The adapter, in addition to providing the interface that the client requests, also provides the interface of the adaptee. • Then the adapter can be used by someone who understands either interface. • A class adapter is automatically two-way, provided that no adaptee methods are overridden in a way that is inconsistent.
Closely related patterns (GoF) • Bridge: separate an interface from its implementation so they can be varied independently. • Decorator: Enhance an object without changing its interface. • Proxy: defines a representative or surrogate for another object without changing its interface.
Other Adapter Issues • Pluggable adapters • Maybe some dayOther issues from anyone else in the class
Façade Pattern • What is it? What is its purpose? • Purpose: To provide a simple interface to services from a complex subsystem.
From wikipedia • There may be a large set of objects with broad uses that are used in conjunction to perform a few functions for client objects. • The façade pattern provides a simplified interface to achieve only those functions needed without having to reference many different, complicated interfaces. • The result is a simple feel to a complicated process.
GOF Example • A software system has a compiler as a subsystem. • The compiler has many components. • Clients don’t care to interact with individual components. • The Compiler façade provides the needed functionality. • Picture on next slide.