Creational design pattern.
Principle:
"Separate out the codes which are subject to change and not subject to change"
Manager (talks to) -> Factory (creates) --> Objects
Factory method:
That method, which has the logic of creating the object based on some certain criteria, are calls "factory method"
Advantage:
1. Avoid code duplication by reusing the creational logic.
2. Separate changing logic vs non changing logic
3. OCP, principle applied
Abstract factory method
MembershipManager (has some concrete policy as general and abstract method for subclass to implement based on region)
LondonMemborshipManager , NYMembershipManager
Principle:
"Separate out the codes which are subject to change and not subject to change"
Manager (talks to) -> Factory (creates) --> Objects
Factory method:
That method, which has the logic of creating the object based on some certain criteria, are calls "factory method"
Advantage:
1. Avoid code duplication by reusing the creational logic.
2. Separate changing logic vs non changing logic
3. OCP, principle applied
Abstract factory method
MembershipManager (has some concrete policy as general and abstract method for subclass to implement based on region)
LondonMemborshipManager , NYMembershipManager
No comments:
Post a Comment