mirror of
https://github.com/DesignPatternsPHP/DesignPatternsPHP.git
synced 2025-08-04 14:07:25 +02:00
README FactoryMethod
This commit is contained in:
@@ -3,17 +3,7 @@
|
|||||||
namespace DesignPatterns\FactoryMethod;
|
namespace DesignPatterns\FactoryMethod;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FactoryMethod is a factory method. The good point over the SimpleFactory
|
* class FactoryMethod
|
||||||
* 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.
|
|
||||||
*/
|
*/
|
||||||
abstract 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.
|
Reference in New Issue
Block a user