Software Design Patterns Flashcards
The scope of a design pattern has to do with what 2 sub-categories?
- Class
- Object
What 2 criteria are used to classify design patterns?
- Purpose
- Scope
What are 2 examples of the Factory Method?
- C# GetEnumerator
- JavaScript createElement
What are Design Patterns?
A generalized way of solving common problems or types of problems in a given field
What are the 3 purpose sub-categories for classifying design patterns?
- Creational
- Structural
- Behavioural
What classification is the Factory method?
Class Creational Pattern
What does a behavioural class pattern do?
Uses inheritance to describe algorithms and flow control
What does a behavioural object pattern do?
Describes how a group of objects cooperate to perform a task that no single object can carry out alone
What does a creational class pattern do?
Defers some part of object creation to subclasses
What does a creational object pattern do?
Defers object creation to another object
What does a structural class pattern do?
Uses inheritance to compose a class
What does a structural object pattern do?
Describes a way to assemble objects
What else is the Factory Method know as?
Virtual Constructor
What is an alternative to using a Singleton pattern?
A Global Variable
What is the intent of a Singleton pattern?
Ensure a class has only one instance, and provide a global point of access to it
What is the intent of the Factory Method?
Define an interface for creating an object and let subclasses decide which class to instantiate
What type of pattern is a Singleton?
Object Creational Pattern
Where does the idea of Software Design Patterns originate from?
Presentation by Kent Beck and Ward Cunningham
Where does the term “Design Pattern” originate?
‘A Pattern Language’
a book about designing towns and buildings
What type of pattern is an Abstract Factory?
Object Creational Pattern
What is the intent of the Abstract Factory?
Provide an interface for creating families of related or dependent objects without specifying their concrete classes
What else is an Abstract Factory known as?
Kit
What type of pattern is Builder?
Object Creational Pattern
What is the intent of the Builder pattern?
Separate the construction of a complex object from its representation to the same construction process can create different representations
When should the Builder pattern be used?
- Algorithm for creating a complex object should be independent of the parts that make up the object
- Construction process must allow different representations for the object that’s constructed
What is the Director in the Builder class?
Accepts a builder and uses it to construct object
How does the Builder create objects that’s different from most creational patterns?
In parts
What type of pattern is Composite?
Object Structural Pattern
What is the intent of the Composite pattern?
Compose objects into tree structures to represent part-whole hierarchies.
What else is an Adapter pattern known as?
Wrapper
What type of pattern is Adapter?
Class and Object Structural Pattern
What is the intent of the Adapter pattern?
Convert the interface of a class into another interface clients expect
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.
Which type of Adapter extends the class you’re trying to wrap?
Class Adapter
What is the purpose of a Two-Way Adapter?
Allow two different clients to view an object differently
What are the 4 participants of the Factory pattern?
- Product
- ConcreteProduct
- Creator
- ConcreteCreator
What is the product in a Factory pattern?
The interface type
What are the 5 participants of the Abstract Factory?
- AbstractFactory
- ConcreteFactory
- AbstractProduct
- ConcreteProduct
- Client
What are the 4 participants of the Builder pattern?
- Builder
- ConcreteBuilder
- Director
- Product
What is passed to the director in a Builder pattern?
ConcreteBuilder
What is a Builder?
An interface
What are the 4 participants of the Composite pattern?
- Component
- Leaf
- Composite
- Client
What does the component do in a Composite pattern?
Declares the interface for objects in the composition.
What are the 4 participants in an Adapter pattern?
- Target
- Client
- Adaptee
- Adapter