Software Design Patterns Flashcards

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?

A

Kit

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
Q

When should the Builder pattern be used?

A
  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
Q

What is the Director in the Builder class?

A

Accepts a builder and uses it to construct object

27
Q

How does the Builder create objects that’s different from most creational patterns?

A

In parts

28
Q

What type of pattern is Composite?

A

Object Structural Pattern

29
Q

What is the intent of the Composite pattern?

A

Compose objects into tree structures to represent part-whole hierarchies.

30
Q

What else is an Adapter pattern known as?

A

Wrapper

31
Q

What type of pattern is Adapter?

A

Class and Object Structural Pattern

32
Q

What is the intent of the Adapter pattern?

A

Convert the interface of a class into another interface clients expect

33
Q

What is the difference between a Class Adapter and an Object Adapter?

A

Object Adapter calls a function on a member variable, whereas a Class Adapter calls a superclass.

34
Q

Which type of Adapter extends the class you’re trying to wrap?

A

Class Adapter

35
Q

What is the purpose of a Two-Way Adapter?

A

Allow two different clients to view an object differently

36
Q

What are the 4 participants of the Factory pattern?

A
  1. Product
  2. ConcreteProduct
  3. Creator
  4. ConcreteCreator
37
Q

What is the product in a Factory pattern?

A

The interface type

38
Q

What are the 5 participants of the Abstract Factory?

A
  1. AbstractFactory
  2. ConcreteFactory
  3. AbstractProduct
  4. ConcreteProduct
  5. Client
39
Q

What are the 4 participants of the Builder pattern?

A
  1. Builder
  2. ConcreteBuilder
  3. Director
  4. Product
40
Q

What is passed to the director in a Builder pattern?

A

ConcreteBuilder

41
Q

What is a Builder?

A

An interface

42
Q

What are the 4 participants of the Composite pattern?

A
  1. Component
  2. Leaf
  3. Composite
  4. Client
43
Q

What does the component do in a Composite pattern?

A

Declares the interface for objects in the composition.

44
Q

What are the 4 participants in an Adapter pattern?

A
  1. Target
  2. Client
  3. Adaptee
  4. Adapter