rfc:customfactories

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:customfactories [2009/11/18 15:20]
robertlemke created
rfc:customfactories [2017/09/22 13:28] (current)
Line 120: Line 120:
  
 Now "​Foo"​ does not depend on any specific implementation,​ neither on an actual ObjectFactory nor on a specific Email implementation. But this comes with a price: At most places where the "​new"​ operator would usually be used to instantiate classes, the ObjectFactory or some other kind of factory needs to be called. If the mechanism of Dependency Injection is consequently used, this results in a lot of additional typing and many classes will need the ObjectFactory getting injected by the surrounding framework. Now "​Foo"​ does not depend on any specific implementation,​ neither on an actual ObjectFactory nor on a specific Email implementation. But this comes with a price: At most places where the "​new"​ operator would usually be used to instantiate classes, the ObjectFactory or some other kind of factory needs to be called. If the mechanism of Dependency Injection is consequently used, this results in a lot of additional typing and many classes will need the ObjectFactory getting injected by the surrounding framework.
- 
 ===== Proposal ===== ===== Proposal =====
  
Line 153: Line 152:
 class Foo { class Foo {
  public function bar() {  public function bar() {
 + // Instantiate by class name:
 + $email = new Email();
 + // or even instantiate by interface name (the factory needs to find the right implementation):​
  $email = new EmailInterface();​  $email = new EmailInterface();​
  }  }
Line 174: Line 176:
 [2] Robert Lemke, "FLOW3 Object Framework"​ [2] Robert Lemke, "FLOW3 Object Framework"​
 http://​flow3.typo3.org/​documentation/​manuals/​flow3/​flow3.objectframework/​ http://​flow3.typo3.org/​documentation/​manuals/​flow3/​flow3.objectframework/​
- 
rfc/customfactories.txt · Last modified: 2017/09/22 13:28 (external edit)