Design Patterns Flashcards
What are the 3 Categories of Design Patterns
- Behavioral
- Creational
- Structural
How many Creational Design Patterns are there? Name them in order.
There are 5 Creational Design Patterns:
- Abstract Factory
- Builder
- Factory
- Prototype
- Singleton
(Abraham Became First President of States)
True or False:
An air traffic controller is a real-life corollary to the
False.
An air traffic controller is an example of the Mediator Behavioral pattern.
Which Design Pattern is defined as:
A fully initialized instance to be copied or cloned?
The Prototype pattern
Which Design Pattern correlates to an initial chess game setup?
The Prototype pattern
True or False:
The Prototype Design Pattern separates object construction from its representation
False.
The Builder pattern separates object construction from its representation
Which Design Pattern correlates to a multi-course dinner (e.g., drinks, appetizer, main course, etc.)?
The Builder pattern correlates to a multi course dinner.
Which Design Pattern is characterized as having only one instance of a particular class?
The Singleton Pattern
True or False: The java.lang.system class is an example of the Singleton pattern.
True
How many Structural Design Patterns are there? Name them.
There are 6 Structural Design Patterns.
- Adapter
- Bridge
- Composite
- Decorator
- Facade
- Flyweight
- Proxy
(“Now I know by ABC’s song: A-B-C-D-F-F-P… “)
Which Design Pattern correlates to a debit card in relation to a bank?
The Proxy pattern
Which Design Pattern is defined as:
An object representing another object?
The Proxy pattern
Which Design Pattern is defined as:
Adding responsibilities to objects dynamically?
The Decorator pattern
Which Design Pattern correlates to a multiple types of pizza with multiple toppings for each
The Decorator pattern
Which Design Pattern correlates to adding a discount to a sale
The Decorator pattern
LineNumberInputStream and BufferedInputStream are two examples of what pattern?
The Decorator pattern
True or False:
An event manager for a party is an example of the Facade pattern
True
Which Design Pattern correlates to a multi-country power adapter?
The Adapter pattern
Which Design Pattern is defined as:
A fine-grained instance used for efficient sharing
The Flyweight pattern
How many Behavioral Design Patterns are there? Name them.
There are 11 Behavioral Design Patterns:
- Method
- Iterator
- Chain of Responsibility
- State
- Mediator
- Interpreter
- Command
- Strategy
- Observer
- Template Method
- Visitor
(“2 Mics On TV” : MiCSMICSOTV)
Exception handling is an example of which Design Pattern?
The Chain of Responsibility pattern
Channel surfing with the “Channel Up / Down” buttons is an example of what pattern?
The Iterator pattern
Which Design Pattern is defined as:
Alter an object’s behavior when its state changes
The State pattern
A ceiling fan wall control is an example of which Design Pattern
The State pattern
True or False:
The Strategy pattern encapsulates an algorithm inside a class
True
True or False:
The Strategy pattern is a way to notify change to a number of classes
False.
The Observer pattern is a way to notify change to a number of classes
What is the Mnemonic for remember Creational Design Patterns?
Abraham Became First President of States
Which Design Pattern is used to separate an object’s abstraction from its implementation
The Bridge pattern
Which Design Pattern is defined as:
A tree structure of simple and composite objects
The Composite pattern
Online bidding submission and outbid notification is an example of which Design Pattern?
The Observer pattern
What is the mnemonic for remembering Behavioral patterns?
“2 Mics On TV”
Dispatching an Uber to pick you up is a real-life corollary to which Design Pattern?
The Observer pattern
Which Design Pattern is used to assign a new operation to a class without changing the class?
The Observer pattern
Which Design Pattern is used to defer a sequence of steps to an algorithm or subclass?
The Template pattern
A house blueprint is a real-life corollary to which Design Pattern?
The Template pattern
java.lang.Runnable is an example of which Design Pattern?
The Command pattern
Which Design Pattern is used to encapsulate a command request as an object
The Command pattern
Which Design Pattern is defined as:
Capturing and restoring an object’s internal state?
The Memento Pattern
Undo / Redo operations are examples of which Design Pattern?
The Memento pattern
Saving your game state is a real-life corollary to which Design Pattern?
The Memento pattern
Which Design Pattern is used to define simplified communication between classes?
The Mediator pattern
The Enterprise Service Bus (ESB) is a real-life example of which Design Pattern?
The Mediator pattern
Which Design Pattern lets the algorithm vary independently from the clients that use it?
The Strategy Pattern
Which Design Pattern is used to design a class that has one behavior that is similar to other behaviors in a list?
The Strategy Pattern
Which Design Pattern to use one of several behaviors dynamically
The Strategy Pattern
Which Design Pattern reduces long lists of conditionals?
The Strategy Pattern
Which Design Pattern keeps class changes from forcing other class changes?
The Strategy Pattern
Which Design Pattern is used when you need to update many other objects when another object changes?
The Observer Pattern
Which Design Pattern is used to return one of several possible classes, chosen at runtime, that share a common super class?
The Factory Pattern