Introducing Design Patterns Flashcards
What are Design Patterns in software engineering?
Design patterns are reusable solutions to common software enginnering problems.
What are the benefits of using Design Patterns?
They help speed up development and improve code quality
What are the 3 categories of Gang Of Four Design Patterns?
Creational
Structural
Behavioural
What is a Creational Design Pattern?
One that deals with object creation
What is a Structural Design Pattern?
One that eases design by identifying simple ways of realizing relationships between objects
What is a Behavioural Design Pattern?
One that helps define how objects interact
What is the Creational Design Pattern known as Factory Pattern used for?
To encapsulate object creation logic making it easier to add new types of objects without modifying existing code.
Example: IAnimal interface and AnimalFactory
What is the Creational Design Pattern known as Singleton used for?
To ensure a class has only one instance and a global point of access to it.
Example: LogManager
What is the Structural Design Pattern known as Decorator used for?
Allows behaviour to be added to an object dynamically without affecting other objects of the same class.
Example: Reading/Writing file. Want to add in buffering, compression…
What is the Structural Design Pattern known as Facade used for?
Provides a simplified interface to complex systems
Example: A system that is accessing multiple API’s
What is the Behavioural Design Pattern known as Iterator used for?
A way to access elements of an objects sequentially without exposing it’s underlying representation.
Example: ICollection
What is the Behavioural Design Pattern known as Observer used for?
Defines a one-to-many dependency between objects so when one changes therest are notified and updated.
Example: BaggageInfo is object observed by screens, customer service etc
What category of the Gang Of Four Design Patterns is the **Repository **Pattern?
It isn’t!
Describe the use of the Repository Pattern?
Mediates between the domain and data layers using a collection like interface for accessing domain objects.
Which Design Pattern is commonly used with the Repository Pattern that ensures changes made to multiple objects in the application are either committed or rolled back?
Unit Of Work, which is a Behavioral Design Pattern