Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
26 Cards in this Set
- Front
- Back
The scope of the adapter pattern?
|
- Class scope
- Structural pattern |
|
The intent of the adapter pattern?
|
- Convert the interface of a class into another interface client expect.
- Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. |
|
The motivation of the adapter pattern?
|
- You have a complex client class that subordinates work to other classes.
- You don’t want to (or can’t) modify the client class every time you use a new subordinate class. |
|
The applicability of the adapter pattern?
|
- You want to use an existing class with an incompatible interface.
- You want to create a reusable class that cooperates with unrelated or unknown classes. - You have to adapt a set of subclasses and it is unreasonable to modify them all. |
|
The consequences of the adapter pattern?
|
- Makes it harder to override Adaptee behaviour.
- Can add functionality to all Adaptees at once. - Can override some of Adaptee’s behaviour. - Since the Adapter is a concrete class, you can’t adapt a class and all of its subclasses. |
|
The scope of the command pattern?
|
- Object scope
- Behavioral pattern - Runtime Focus on activity, not structure |
|
The intent of the command pattern?
|
- Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations
- Encapsulate all the information needed to call a method at later time. |
|
The motivation of the command pattern?
|
- The necessity of issuing requests to objects without knowing anything about the operation being requested or the receiver of the request.
- As in GUIs elements like toolbar buttons, menu items, etc. |
|
The applicability of the command pattern?
|
- GUI elements like buttons and menu items (Java’s Swing Action class).
- Macro recording. - Mobile code (code that moves to different locations while executing) needs routable commands. - Multi-level undo (command object will contain an undo() method). - Networked application needs to send the command to another machine (object must be serializable). - Concurrent processing: rout the command object to the appropriate thread. - Parallel processing: rout the command object to each of the threads. - Transactional behavior: unwind multipart transaction that fail before all parts complete |
|
The consequences of the command pattern?
|
- Decouples the object that invokes the operation from the one that knows how to perform it.
- Command objects are first class objects. They can be manipulated and extended. - Commands can be made composite commands (usually with the composite pattern). - Easy to add more commands. |
|
The scope of the observer pattern?
|
- Object scope
- Behavioral pattern |
|
The intent of the observer pattern?
|
- Define a one-to-many dependency between objects so that when one object changes, all its dependents are notified and updated automatically.
|
|
The motivation of the observer pattern?
|
- Maintain consistency between related objects without tight coupling
|
|
The applicability of the observer pattern?
|
- GUIs.
- Key part of MVC pattern. - Implementing distributed event handling systems. |
|
The consequences of the observer pattern?
|
Abstract coupling between Subject and Observer.
- Subject and observer can be located in separate layers of a system. Support of broadcast communication. - Senders don’t need to know who the receivers are. Unexpected Updates - Observers don’t know about each other, and can cause a cascade of updates or even an endless cycle |
|
Command pattern is also known as?
|
- Action
- Transaction |
|
Participants in the observer pattern?
|
Subject
- Knows its observers. - Provides interface for attaching and detaching observers. Observer (abstract) - Defines an updating interface for objects notified by the subject. Subject (concrete) - Stores the state of interest to the (concrete) observer objects. Observer (concrete) - Maintains a reference to the concrete subject - Stores the state that must stay consistent with the subject’s - Implements the (abstract) observer update interface. |
|
4 important ideas in command pattern?
|
- Command
- Receiver - Invoker - Client |
|
Terminology: Command?
|
- Names: command object, routed command object, action object.
- Represents the command within the system. - Typically contain an execute() method. |
|
Terminology: Receiver?
|
- Names: receiver, target object.
- The object that receives the command. - The object whose method is called by Command::execute(). |
|
Terminology: Invoker?
|
- Names: invoker, client, source.
- The object that creates the command object. - May also perform bookkeeping (for undo). - The button, menu item, key press, etc. |
|
Terminology: Client?
|
- Names: client, application.
- The object that owns the invoker and the commands. |
|
Observer pattern is also known as?
|
- Dependents Pattern
- Publish-Subscribe Pattern |
|
Where did we implement adapter pattern in project 3/4?
|
Console API
|
|
Where did we implement singleton pattern in project 3/4?
|
Console framework
|
|
Where did we implement MVC pattern in project 3/4?
|
• Model is folder/recursion/filter and results
• View is console TUI (implements Observer Pattern) • Controller manages communication between Model and View (implements command pattern) |