Design Patterns Flashcards
Which pattern is used for 1 to many relationships between objects?
Observer Pattern
What are the actors used in observer patterns?
- Subject
- Object
- Client
What is a subject(Observable) actor in the Observer pattern?
It holds methods to attach and detach the observers to the client. it is a concrete class that extends the observer class
What is an Observer?
The observer is an abstract class with all the methods
What are design patterns?
Capture the best practice of experienced object-oriented s/w developers
What are the essential elements of patterns?
- Name
- Problem and its context
- Solution with an abstract description
- Consequences
Types of design patterns?
Creational Patterns
Structural Patterns
State Patterns
Command patterns
What are creational Patterns?
Create an object for you rather than having you to instantiate an object
What are Structural Patterns?
how to group. and organize classes
What are state patterns?
Class behavior changes on the basis of State
What are the elements of the state pattern?
- Context
- State
- ConcreteState
What is Context in state pattern?
The object whose behavior needs to be state-specific
It will have reference to a concrete state, which defines the current state of the context object. The state is proportional to Context.
What is State class in State Pattern?
It is implemented as an abstract class/Interface
What is a Concrete State in State Pattern?
The class that implements state-specific behavior, have the implementation of setState()
What is a Command Pattern?
It is a data-driven design pattern and falls under the behavior pattern category