Design Patterns Flashcards

1
Q

What is a design pattern?

A

Provide general reusable solutions to one type of problems during software development, they provide an architecture.

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

Why would you use a design pattern?

A

Avoids reinventing the wheel, reuses designs and solutions that have proved useful in the past by experienced object-oriented designers.

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

What are the types of design patterns?

A

Creational Patterns
Structural Patterns
Behavioral Patterns

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

What are creational patterns?

A

Abstraction of instantiation process.

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

What are structural patterns?

A

Composition of classes and objects.

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

What are behavioral patterns?

A

Interaction between objects.

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

What does the Factory Pattern do?

A

Defines an interface for creating an object, but lets subclasses decide which class to instantiate. It lets a class defer instantiation to subclasses. (uses abstract class PizzaShop)

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

What is the Abstract Factory Pattern?

A

Provides an interface for creating families of related dependent objects without specifying their concrete classes. (uses interface PizzaIngredientFactory which the concrete subclasses implement)

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

What is the Builder Pattern?

A

Separates the construction of a complex object from its representation so that the same construction processes can create different representations.
Allows you to vary a products internal representation
Isolates code for construction and representation
Finer control over the construction process

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

In the Builder Pattern how does the Builder work?

A

The builder specifies the interface for creating parts of the complex (product) object.

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

In the Builder Pattern how does the ConcreteBuilder work?

A

The concrete builder objects create and assemble the parts that make up the product through the builder interface.

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

In the Builder Pattern how does the Director work?

A

The director object takes responsibility for the construction process of the complex (Product) object, however it delegates the actual creation and assembly to the Builder interface.

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

In the Builder Pattern how does the Product work?

A

The product represents the complex object that is created by the concretebuilder object. The product consists of multiple parts that are created separately by the concrete builder objects.

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

Builder pattern pseudocode

A
TopLevelClass
creates specific pizza builder
creates director (waiter)
waiter.setPizzaBuilder(pizza builder)
waiter.constructPizza
waiter.getPizza.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Benefits of the builder pattern

A

Encapsulates the way a complex object is constructed
Allows objects to be constructed in a multistep and varying process
Hides the internal representation of the product from the client.

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

What is the command pattern?

A

Encapsulates a request as an object, letting you parametereise other objects with different requests, queue or log requests, and support undoable operations.