Design Patterns Flashcards

1
Q

What do Creational patterns deal with?

A

How an object is created

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

What are the two basic ideas behind creational design patterns?

A
  1. Encapsulating the knowledge of which concrete types should be created
  2. Hiding how the instances of these types are created
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

List five well-known patterns that are part of the creational pattern category.

A
  1. The abstract factory pattern
  2. The builder pattern
  3. The factory method pattern
  4. The prototype pattern
  5. The singleton pattern
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the abstract factory pattern do?

A

Provides an interface for creating related objects without specifying the concrete type

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

What does the builder pattern do?

A

Separates the construction of a complex object from its representation, so the same process can be used to create similar types.

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

What does the factory method pattern do?

A

Creates objects without exposing the underlying logic of how the object (or which type of object) is created.

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

What does the prototype pattern do?

A

Creates an object by cloning an existing one.

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

What does the singleton pattern do?

A

Allows one (and only one) instance of a class for the lifetime of an application.

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

What are structural patterns?

A

Structural patterns concern types and object compositions

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

What do behavioural patterns do?

A

Communicate between types.

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

What do structural design patterns describe?

A

How types can be combined to form larger structures.

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

List seven well-known patterns that are part of the structural design pattern type?

A
  1. Adapter
  2. Bridge
  3. Composite
  4. Decorator
  5. Facade
  6. Flyweight
  7. Proxy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What does the adapter pattern do?

A

Allows types with incompatible interfaces to work together

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

What is the bridge pattern used for?

A

To separate the abstract elements of a type from the implementation so the two can vary.

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

What does the composite pattern do?

A

Allows the application to treat a group of objects as a single object.

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

What does the decorator pattern do?

A

Lets us add or override behavior in an existing method of an object.

17
Q

What does the facade pattern do?

A

It provides a simplified interface for a larger and more complex body of code.

18
Q

What does the flyweight pattern do?

A

It allows us to reduce the resources needed to create and use a large number of similar objects.

19
Q

What is the proxy pattern?

A

This is a type acting as an interface for another class or classes.

20
Q

What do behavioral design patterns do?

A

They explain how types interact with each other.

21
Q

List 9 well-known patterns that are part of the behavioral design pattern type

A
  1. Chain of responsibility
  2. Command
  3. Iterator
  4. Mediator
  5. Memento
  6. Observer
  7. State
  8. Strategy
  9. Visitor
22
Q

What is the chain of responsibility design pattern used for?

A

To process a variety of requests, each of which may be delegated to a different handler

23
Q

What does the command design pattern do?

A

Creates objects that can encapsulate actions or parameters so that they can be invoked later or by a different component.

24
Q

What does the iterator design pattern do?

A

Allows us to access the elements of an object sequentially without exposing the underlying structure.

25
Q

What is the mediator design pattern used for?

A

To reduce coupling between types that communicate with each other.

26
Q

What is the memento design pattern used for?

A

To capture the current state of an object and store it in a manner that an be restored later.

27
Q

What does the observer design pattern do?

A

It allows an object to publish changes to an object’s state. Other objects can then subscribe so they can be notified of any changes.

28
Q

What is the state design pattern used to do?

A

To alter the behavior of an object when its internal state changes.

29
Q

What does the strategy design pattern do?

A

It allows one out of a family of algorithms to be chosen at runtime.

30
Q

What is the visitor design pattern?

A

This is a way of separating an algorithm from an object structure.