6. Design Pattern Questions Flashcards
What’s dependency injection?
Dependency injection is the ability to supply an external dependency into a component. It helps us develop loosely coupled code.
What are the three ways of implementing dependency injection?
- Constructor injection
- Property injection
- Method injection
Who are the gang of four?
The authors of the book Design Patterns: Elements of Reusable Object-Oriented Software
What are the three types of design patterns?
- Creational patterns
- Structural patterns
- Behavioral patterns
What is a creational pattern?
Ways to create objects while hiding the creation logic.
What is a structural pattern?
A design pattern that deals with class and object composition, and use inheritance to compose interfaces and objects for functionality.
What is a behavioural pattern?
Design patterns that are concerned with communication between objects.
What are the five creational design patterns?
- Abstract Factory
- Bulder
- Factory Method
- Prototype
- Singleton
What is the Abstract Factory pattern?
A creational design pattern that creates an instance of several families of classes.
What is the Builder pattern?
A creational design pattern that separates object construction from its representation.
What is the Factory Method pattern?
A creational design pattern that creates an instance of several derived classes.
What is the Prototype pattern?
A creational design pattern that produces a fully initialised instance to be copied or cloned.
What is the Singleton pattern?
A design pattern that produces a class of which only a single instance can exist.
What are seven structural design patterns?
- Adapter
- Bridge
- Composite
- Decorator
- Facade
- Flyweight
- Proxy
What is the Adapter pattern?
A structural design pattern that matches interfaces of different classes.
What is the Bridge pattern?
A structural design pattern that separates an object’s interface from its implementation.
What is the Composite pattern?
A structural design pattern that is a tree structure of simple and composite objects.
What is the Decorator pattern?
A structural design pattern that adds responsibilities to objects dynamically.
What is the Facade pattern?
A structural design pattern that is a single class that represents an entire subsystem.
What is the Flyweight pattern?
A structural design pattern that is a fine-grained instance used for efficient sharing.
What is the Proxy pattern?
A structural design pattern that is an object representing another object.
What are the eleven behavioral design patterns?
- Chain of Responsibility
- Command
- Interpreter
- Iterator
- Mediator
- Memento
- Observer
- State
- Strategy
- Template Method
- Visitor
What is the Chain of Responsibility pattern?
A behavioural design pattern that is a way of passing a request between a chain of objects.
What is the Comand pattern?
A behavioural design pattern that encapsulates a command request as an object.
What is the Interpreter pattern?
A behavioural design pattern that is a way to include language elements in a program.
What is the Iterator pattern?
A behavioural design pattern that allows sequential access to the elements of a collection.
What is the Mediator pattern?
A behavioural design pattern that defines simplified communication between classes.
What is the Memento pattern?
A behavioural design pattern that captures and restores an object’s internal state.
What is the Observer pattern?
A behavioural design pattern that provides a way of notifying change to a number of classes.
What is the State pattern?
A behavioural design pattern that alters an object’s behaviour when its state changes.
What is the Strategy pattern?
A behavioural design pattern that encapsulates an algorithm inside a class.
What is the Template Method pattern?
A behavioural design pattern that defers the exact steps of an algorithm to a subclass.
What is the Visitor pattern?
A behavioural design pattern that defines a new operation to a class without change.
What is the Repository pattern?
A design pattern that provides an abstraction of data so that your application can work with inserting, removing, updating, and selecting items (CRUD).
What is the Unit of Work pattern?
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.