Design Patterns Flashcards
What do Creational patterns deal with?
How an object is created
What are the two basic ideas behind creational design patterns?
- Encapsulating the knowledge of which concrete types should be created
- Hiding how the instances of these types are created
List five well-known patterns that are part of the creational pattern category.
- The abstract factory pattern
- The builder pattern
- The factory method pattern
- The prototype pattern
- The singleton pattern
What does the abstract factory pattern do?
Provides an interface for creating related objects without specifying the concrete type
What does the builder pattern do?
Separates the construction of a complex object from its representation, so the same process can be used to create similar types.
What does the factory method pattern do?
Creates objects without exposing the underlying logic of how the object (or which type of object) is created.
What does the prototype pattern do?
Creates an object by cloning an existing one.
What does the singleton pattern do?
Allows one (and only one) instance of a class for the lifetime of an application.
What are structural patterns?
Structural patterns concern types and object compositions
What do behavioural patterns do?
Communicate between types.
What do structural design patterns describe?
How types can be combined to form larger structures.
List seven well-known patterns that are part of the structural design pattern type?
- Adapter
- Bridge
- Composite
- Decorator
- Facade
- Flyweight
- Proxy
What does the adapter pattern do?
Allows types with incompatible interfaces to work together
What is the bridge pattern used for?
To separate the abstract elements of a type from the implementation so the two can vary.
What does the composite pattern do?
Allows the application to treat a group of objects as a single object.
What does the decorator pattern do?
Lets us add or override behavior in an existing method of an object.
What does the facade pattern do?
It provides a simplified interface for a larger and more complex body of code.
What does the flyweight pattern do?
It allows us to reduce the resources needed to create and use a large number of similar objects.
What is the proxy pattern?
This is a type acting as an interface for another class or classes.
What do behavioral design patterns do?
They explain how types interact with each other.
List 9 well-known patterns that are part of the behavioral design pattern type
- Chain of responsibility
- Command
- Iterator
- Mediator
- Memento
- Observer
- State
- Strategy
- Visitor
What is the chain of responsibility design pattern used for?
To process a variety of requests, each of which may be delegated to a different handler
What does the command design pattern do?
Creates objects that can encapsulate actions or parameters so that they can be invoked later or by a different component.
What does the iterator design pattern do?
Allows us to access the elements of an object sequentially without exposing the underlying structure.
What is the mediator design pattern used for?
To reduce coupling between types that communicate with each other.
What is the memento design pattern used for?
To capture the current state of an object and store it in a manner that an be restored later.
What does the observer design pattern do?
It allows an object to publish changes to an object’s state. Other objects can then subscribe so they can be notified of any changes.
What is the state design pattern used to do?
To alter the behavior of an object when its internal state changes.
What does the strategy design pattern do?
It allows one out of a family of algorithms to be chosen at runtime.
What is the visitor design pattern?
This is a way of separating an algorithm from an object structure.