6. Design Pattern Questions Flashcards

1
Q

What’s dependency injection?

A

Dependency injection is the ability to supply an external dependency into a component. It helps us develop loosely coupled code.

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

What are the three ways of implementing dependency injection?

A
  1. Constructor injection
  2. Property injection
  3. Method injection
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Who are the gang of four?

A

The authors of the book Design Patterns: Elements of Reusable Object-Oriented Software

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

What are the three types of design patterns?

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

What is a creational pattern?

A

Ways to create objects while hiding the creation logic.

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

What is a structural pattern?

A

A design pattern that deals with class and object composition, and use inheritance to compose interfaces and objects for functionality.

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

What is a behavioural pattern?

A

Design patterns that are concerned with communication between objects.

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

What are the five creational design patterns?

A
  1. Abstract Factory
  2. Bulder
  3. Factory Method
  4. Prototype
  5. Singleton
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the Abstract Factory pattern?

A

A creational design pattern that creates an instance of several families of classes.

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

What is the Builder pattern?

A

A creational design pattern that separates object construction from its representation.

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

What is the Factory Method pattern?

A

A creational design pattern that creates an instance of several derived classes.

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

What is the Prototype pattern?

A

A creational design pattern that produces a fully initialised instance to be copied or cloned.

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

What is the Singleton pattern?

A

A design pattern that produces a class of which only a single instance can exist.

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

What are seven structural design patterns?

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

What is the Adapter pattern?

A

A structural design pattern that matches interfaces of different classes.

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

What is the Bridge pattern?

A

A structural design pattern that separates an object’s interface from its implementation.

17
Q

What is the Composite pattern?

A

A structural design pattern that is a tree structure of simple and composite objects.

18
Q

What is the Decorator pattern?

A

A structural design pattern that adds responsibilities to objects dynamically.

19
Q

What is the Facade pattern?

A

A structural design pattern that is a single class that represents an entire subsystem.

20
Q

What is the Flyweight pattern?

A

A structural design pattern that is a fine-grained instance used for efficient sharing.

21
Q

What is the Proxy pattern?

A

A structural design pattern that is an object representing another object.

22
Q

What are the eleven behavioral design patterns?

A
  1. Chain of Responsibility
  2. Command
  3. Interpreter
  4. Iterator
  5. Mediator
  6. Memento
  7. Observer
  8. State
  9. Strategy
  10. Template Method
  11. Visitor
23
Q

What is the Chain of Responsibility pattern?

A

A behavioural design pattern that is a way of passing a request between a chain of objects.

24
Q

What is the Comand pattern?

A

A behavioural design pattern that encapsulates a command request as an object.

25
Q

What is the Interpreter pattern?

A

A behavioural design pattern that is a way to include language elements in a program.

26
Q

What is the Iterator pattern?

A

A behavioural design pattern that allows sequential access to the elements of a collection.

27
Q

What is the Mediator pattern?

A

A behavioural design pattern that defines simplified communication between classes.

28
Q

What is the Memento pattern?

A

A behavioural design pattern that captures and restores an object’s internal state.

29
Q

What is the Observer pattern?

A

A behavioural design pattern that provides a way of notifying change to a number of classes.

30
Q

What is the State pattern?

A

A behavioural design pattern that alters an object’s behaviour when its state changes.

31
Q

What is the Strategy pattern?

A

A behavioural design pattern that encapsulates an algorithm inside a class.

32
Q

What is the Template Method pattern?

A

A behavioural design pattern that defers the exact steps of an algorithm to a subclass.

33
Q

What is the Visitor pattern?

A

A behavioural design pattern that defines a new operation to a class without change.

34
Q

What is the Repository pattern?

A

A design pattern that provides an abstraction of data so that your application can work with inserting, removing, updating, and selecting items (CRUD).

35
Q

What is the Unit of Work pattern?

A

A design pattern that maintains in-memory updates

and then sends them as one transaction to the database. It’s often used with the Repository pattern.