Software Design Patterns Flashcards

(44 cards)

1
Q

The scope of a design pattern has to do with what 2 sub-categories?

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

What 2 criteria are used to classify design patterns?

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

What are 2 examples of the Factory Method?

A
  1. C# GetEnumerator
  2. JavaScript createElement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are Design Patterns?

A

A generalized way of solving common problems or types of problems in a given field

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

What are the 3 purpose sub-categories for classifying design patterns?

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

What classification is the Factory method?

A

Class Creational Pattern

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

What does a behavioural class pattern do?

A

Uses inheritance to describe algorithms and flow control

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

What does a behavioural object pattern do?

A

Describes how a group of objects cooperate to perform a task that no single object can carry out alone

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

What does a creational class pattern do?

A

Defers some part of object creation to subclasses

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

What does a creational object pattern do?

A

Defers object creation to another object

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

What does a structural class pattern do?

A

Uses inheritance to compose a class

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

What does a structural object pattern do?

A

Describes a way to assemble objects

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

What else is the Factory Method know as?

A

Virtual Constructor

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

What is an alternative to using a Singleton pattern?

A

A Global Variable

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

What is the intent of a Singleton pattern?

A

Ensure a class has only one instance, and provide a global point of access to it

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

What is the intent of the Factory Method?

A

Define an interface for creating an object and let subclasses decide which class to instantiate

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

What type of pattern is a Singleton?

A

Object Creational Pattern

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

Where does the idea of Software Design Patterns originate from?

A

Presentation by Kent Beck and Ward Cunningham

19
Q

Where does the term “Design Pattern” originate?

A

‘A Pattern Language’
a book about designing towns and buildings

20
Q

What type of pattern is an Abstract Factory?

A

Object Creational Pattern

21
Q

What is the intent of the Abstract Factory?

A

Provide an interface for creating families of related or dependent objects without specifying their concrete classes

22
Q

What else is an Abstract Factory known as?

23
Q

What type of pattern is Builder?

A

Object Creational Pattern

24
Q

What is the intent of the Builder pattern?

A

Separate the construction of a complex object from its representation to the same construction process can create different representations

25
When should the Builder pattern be used?
1. Algorithm for creating a complex object should be independent of the parts that make up the object 2. Construction process must allow different representations for the object that's constructed
26
What is the Director in the Builder class?
Accepts a builder and uses it to construct object
27
How does the Builder create objects that's different from most creational patterns?
In parts
28
What type of pattern is Composite?
Object Structural Pattern
29
What is the intent of the Composite pattern?
Compose objects into tree structures to represent part-whole hierarchies.
30
What else is an Adapter pattern known as?
Wrapper
31
What type of pattern is Adapter?
Class and Object Structural Pattern
32
What is the intent of the Adapter pattern?
Convert the interface of a class into another interface clients expect
33
What is the difference between a Class Adapter and an Object Adapter?
Object Adapter calls a function on a member variable, whereas a Class Adapter calls a superclass.
34
Which type of Adapter extends the class you're trying to wrap?
Class Adapter
35
What is the purpose of a Two-Way Adapter?
Allow two different clients to view an object differently
36
What are the 4 participants of the Factory pattern?
1. Product 2. ConcreteProduct 3. Creator 4. ConcreteCreator
37
What is the product in a Factory pattern?
The interface type
38
What are the 5 participants of the Abstract Factory?
1. AbstractFactory 2. ConcreteFactory 3. AbstractProduct 4. ConcreteProduct 5. Client
39
What are the 4 participants of the Builder pattern?
1. Builder 2. ConcreteBuilder 3. Director 4. Product
40
What is passed to the director in a Builder pattern?
ConcreteBuilder
41
What is a Builder?
An interface
42
What are the 4 participants of the Composite pattern?
1. Component 2. Leaf 3. Composite 4. Client
43
What does the component do in a Composite pattern?
Declares the interface for objects in the composition.
44
What are the 4 participants in an Adapter pattern?
1. Target 2. Client 3. Adaptee 4. Adapter