Factory method pattern: Difference between revisions

Content deleted Content added
Descriptive names: Add comment on private constructors
Line 9:
The creator needs to create instances of products, but the concrete type of product should not be hardcoded in the creator – subclasses of creator should be able to specify subclasses of product to use.
 
To achiveachieve this an abstract method (the factory method) is defined on the creator.
This method is defined to return a product.
Subclasses of creator can override this method to return instances of appropriate subclasses of product.