Design Patterns Flashcards

(49 cards)

1
Q

What are the 3 Categories of Design Patterns

A
  1. Behavioral
  2. Creational
  3. Structural
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How many Creational Design Patterns are there? Name them in order.

A

There are 5 Creational Design Patterns:

  1. Abstract Factory
  2. Builder
  3. Factory
  4. Prototype
  5. Singleton

(Abraham Became First President of States)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

True or False:

An air traffic controller is a real-life corollary to the

A

False.

An air traffic controller is an example of the Mediator Behavioral pattern.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which Design Pattern is defined as:

A fully initialized instance to be copied or cloned?

A

The Prototype pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Which Design Pattern correlates to an initial chess game setup?

A

The Prototype pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

True or False:

The Prototype Design Pattern separates object construction from its representation

A

False.

The Builder pattern separates object construction from its representation

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which Design Pattern correlates to a multi-course dinner (e.g., drinks, appetizer, main course, etc.)?

A

The Builder pattern correlates to a multi course dinner.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Which Design Pattern is characterized as having only one instance of a particular class?

A

The Singleton Pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
True or False:
The java.lang.system class is an example of the Singleton pattern.
A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How many Structural Design Patterns are there? Name them.

A

There are 6 Structural Design Patterns.

  1. Adapter
  2. Bridge
  3. Composite
  4. Decorator
  5. Facade
  6. Flyweight
  7. Proxy

(“Now I know by ABC’s song: A-B-C-D-F-F-P… “)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which Design Pattern correlates to a debit card in relation to a bank?

A

The Proxy pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Which Design Pattern is defined as:

An object representing another object?

A

The Proxy pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Which Design Pattern is defined as:

Adding responsibilities to objects dynamically?

A

The Decorator pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Which Design Pattern correlates to a multiple types of pizza with multiple toppings for each

A

The Decorator pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which Design Pattern correlates to adding a discount to a sale

A

The Decorator pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

LineNumberInputStream and BufferedInputStream are two examples of what pattern?

A

The Decorator pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

True or False:

An event manager for a party is an example of the Facade pattern

A

True

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

Which Design Pattern correlates to a multi-country power adapter?

A

The Adapter pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

Which Design Pattern is defined as:

A fine-grained instance used for efficient sharing

A

The Flyweight pattern

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

How many Behavioral Design Patterns are there? Name them.

A

There are 11 Behavioral Design Patterns:

  1. Method
  2. Iterator
  3. Chain of Responsibility
  4. State
  5. Mediator
  6. Interpreter
  7. Command
  8. Strategy
  9. Observer
  10. Template Method
  11. Visitor

(“2 Mics On TV” : MiCSMICSOTV)

21
Q

Exception handling is an example of which Design Pattern?

A

The Chain of Responsibility pattern

22
Q

Channel surfing with the “Channel Up / Down” buttons is an example of what pattern?

A

The Iterator pattern

23
Q

Which Design Pattern is defined as:

Alter an object’s behavior when its state changes

A

The State pattern

24
Q

A ceiling fan wall control is an example of which Design Pattern

A

The State pattern

25
True or False: | The Strategy pattern encapsulates an algorithm inside a class
True
26
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
27
What is the Mnemonic for remember Creational Design Patterns?
Abraham Became First President of States
28
Which Design Pattern is used to separate an object’s abstraction from its implementation
The Bridge pattern
29
Which Design Pattern is defined as: | A tree structure of simple and composite objects
The Composite pattern
30
Online bidding submission and outbid notification is an example of which Design Pattern?
The Observer pattern
31
What is the mnemonic for remembering Behavioral patterns?
"2 Mics On TV"
32
Dispatching an Uber to pick you up is a real-life corollary to which Design Pattern?
The Observer pattern
33
Which Design Pattern is used to assign a new operation to a class without changing the class?
The Observer pattern
34
Which Design Pattern is used to defer a sequence of steps to an algorithm or subclass?
The Template pattern
35
A house blueprint is a real-life corollary to which Design Pattern?
The Template pattern
36
java.lang.Runnable is an example of which Design Pattern?
The Command pattern
37
Which Design Pattern is used to encapsulate a command request as an object
The Command pattern
38
Which Design Pattern is defined as: | Capturing and restoring an object's internal state?
The Memento Pattern
39
Undo / Redo operations are examples of which Design Pattern?
The Memento pattern
40
Saving your game state is a real-life corollary to which Design Pattern?
The Memento pattern
41
Which Design Pattern is used to define simplified communication between classes?
The Mediator pattern
42
The Enterprise Service Bus (ESB) is a real-life example of which Design Pattern?
The Mediator pattern
43
Which Design Pattern lets the algorithm vary independently from the clients that use it?
The Strategy Pattern
44
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
45
Which Design Pattern to use one of several behaviors dynamically
The Strategy Pattern
46
Which Design Pattern reduces long lists of conditionals?
The Strategy Pattern
47
Which Design Pattern keeps class changes from forcing other class changes?
The Strategy Pattern
48
Which Design Pattern is used when you need to update many other objects when another object changes?
The Observer Pattern
49
Which Design Pattern is used to return one of several possible classes, chosen at runtime, that share a common super class?
The Factory Pattern