Design Patterns Flashcards

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
Q

True or False:

The Strategy pattern encapsulates an algorithm inside a class

A

True

26
Q

True or False:

The Strategy pattern is a way to notify change to a number of classes

A

False.

The Observer pattern is a way to notify change to a number of classes

27
Q

What is the Mnemonic for remember Creational Design Patterns?

A

Abraham Became First President of States

28
Q

Which Design Pattern is used to separate an object’s abstraction from its implementation

A

The Bridge pattern

29
Q

Which Design Pattern is defined as:

A tree structure of simple and composite objects

A

The Composite pattern

30
Q

Online bidding submission and outbid notification is an example of which Design Pattern?

A

The Observer pattern

31
Q

What is the mnemonic for remembering Behavioral patterns?

A

“2 Mics On TV”

32
Q

Dispatching an Uber to pick you up is a real-life corollary to which Design Pattern?

A

The Observer pattern

33
Q

Which Design Pattern is used to assign a new operation to a class without changing the class?

A

The Observer pattern

34
Q

Which Design Pattern is used to defer a sequence of steps to an algorithm or subclass?

A

The Template pattern

35
Q

A house blueprint is a real-life corollary to which Design Pattern?

A

The Template pattern

36
Q

java.lang.Runnable is an example of which Design Pattern?

A

The Command pattern

37
Q

Which Design Pattern is used to encapsulate a command request as an object

A

The Command pattern

38
Q

Which Design Pattern is defined as:

Capturing and restoring an object’s internal state?

A

The Memento Pattern

39
Q

Undo / Redo operations are examples of which Design Pattern?

A

The Memento pattern

40
Q

Saving your game state is a real-life corollary to which Design Pattern?

A

The Memento pattern

41
Q

Which Design Pattern is used to define simplified communication between classes?

A

The Mediator pattern

42
Q

The Enterprise Service Bus (ESB) is a real-life example of which Design Pattern?

A

The Mediator pattern

43
Q

Which Design Pattern lets the algorithm vary independently from the clients that use it?

A

The Strategy Pattern

44
Q

Which Design Pattern is used to design a class that has one behavior that is similar to other behaviors in a list?

A

The Strategy Pattern

45
Q

Which Design Pattern to use one of several behaviors dynamically

A

The Strategy Pattern

46
Q

Which Design Pattern reduces long lists of conditionals?

A

The Strategy Pattern

47
Q

Which Design Pattern keeps class changes from forcing other class changes?

A

The Strategy Pattern

48
Q

Which Design Pattern is used when you need to update many other objects when another object changes?

A

The Observer Pattern

49
Q

Which Design Pattern is used to return one of several possible classes, chosen at runtime, that share a common super class?

A

The Factory Pattern