[1Day-1CS] Factory Pattern, Strategy Pattern, and Observer Pattern
A Brief Summary of the Singleton Pattern, Factory Pattern, Strategy Pattern, and Observer Pattern
Factory Pattern
-
A pattern that abstracts the object creation process from the code that uses the objects
-
The superclass determines the essential framework
-
The subclass determines the specific details of object creation
Characteristics and Advantages of the Factory Pattern
Achieves loose coupling through class separation
Ensures flexibility in the superclass and improves maintainability
Strategy Pattern
Context
-
Refers to the relevant information required for a developer to complete a task
-
There exists a mandatory context essential for an action to occur, as well as an optional context for the effective execution of the action.
Observer Pattern
-
A subject observes state changes in a specific object
-
When a state change occurs, the subject notifies observers of the change via methods, etc.
-
Sometimes built based on mutable objects rather than separating the subject and the object
-
Also utilized in the MVC pattern