Writing a factory for classes that have required arguments
Posted
by
Kyle Adams
on Stack Overflow
See other posts from Stack Overflow
or by Kyle Adams
Published on 2012-12-14T23:00:10Z
Indexed on
2012/12/14
23:03 UTC
Read the original article
Hit count: 346
php
|factory-pattern
I understand the concept of factory pattern such that you give it something it spits out something of the same template back so if I gave a factory class apple, I expect to get many apples back with out having to instantiate a new apple ever time.
what if that apple has a required argument of seed, or multiple required arguments of seed, step and leaf? how do you use factory pattern here?
that is how do I use factory pattern to instantiate this:
$apple = new Apple($seed, $stem, $leaf);
© Stack Overflow or respective owner