mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-02-24 09:42:24 +01:00
README FactoryMethod
This commit is contained in:
parent
d618d2068a
commit
851aa0a0d8
@ -3,17 +3,7 @@
|
||||
namespace DesignPatterns\FactoryMethod;
|
||||
|
||||
/**
|
||||
* FactoryMethod is a factory method. The good point over the SimpleFactory
|
||||
* is you can subclass it to implement different way to create vehicle for
|
||||
* each country (see subclasses)
|
||||
*
|
||||
* For simple case, this abstract class could be just an interface
|
||||
*
|
||||
* This pattern is a "real" Design Pattern because it achieves the
|
||||
* "Dependency Inversion Principle" a.k.a the "D" in S.O.L.I.D principles.
|
||||
*
|
||||
* It means the FactoryMethod class depends on abstractions not concrete classes.
|
||||
* This is the real trick compared to SImpleFactory or StaticFactory.
|
||||
* class FactoryMethod
|
||||
*/
|
||||
abstract class FactoryMethod
|
||||
{
|
||||
|
11
FactoryMethod/README.md
Normal file
11
FactoryMethod/README.md
Normal file
@ -0,0 +1,11 @@
|
||||
# Factory Method
|
||||
|
||||
## Purpose
|
||||
|
||||
The good point over the SimpleFactory is you can subclass it to implement different ways to create objects
|
||||
|
||||
For simple case, this abstract class could be just an interface
|
||||
|
||||
This pattern is a "real" Design Pattern because it achieves the "Dependency Inversion Principle" a.k.a the "D" in S.O.L.I.D principles.
|
||||
|
||||
It means the FactoryMethod class depends on abstractions, not concrete classes. This is the real trick compared to SimpleFactory or StaticFactory.
|
Loading…
x
Reference in New Issue
Block a user