mirror of
https://github.com/tiennm99/java-design-patterns.git
synced 2026-05-15 04:59:24 +00:00
fbb12b53ba
I did the job and splitted up the readme, hopefully everything was splitted correctly...
677 B
677 B
layout, title, folder, categories, tags
| layout | title | folder | categories | tags |
|---|---|---|---|---|
| pattern | Factory Method | factory-method | creational | pattern_tag |
Intent: Define an interface for creating an object, but let subclasses decide which class to instantiate. Factory Method lets a class defer instantiation to subclasses.
Applicability: Use the Factory Method pattern when
- a class can't anticipate the class of objects it must create
- a class wants its subclasses to specify the objects it creates
- classes delegate responsibility to one of several helper subclasses, and you want to localize the knowledge of which helper subclass is the delegate
