21 ms·
When you know in advance which object to use and object does not require configuration, instantiate that object without factory or dynamic construct. The facto
by watwut 8y ago
When you know in advance which object to use and object does not require configuration, instantiate that object without factory or dynamic construct.
The factory is useful only if you are a.) about to wire object into something complex or b.) create it based on complicated external rules or c.) decided that some group of objects is better to be initialized all at the same place for code readability (rare). Even in java, there is not other use.
As in, your php code foes not replaces factory and using factory where you phone code works is unnecessary overkill.