News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Giorgio Sironi's Blog:
When to inject the distinction between newables and injectables
July 31, 2009 @ 10:58:39

Following up on a previous post about dependency injection, Giorgio Sironi has posted this new look at when to use dependency injection and when its still better to handle objects individually.

In the last post, I introduced Dependency Injection and show useful cases where it allows classes decouplng. I also wrote about the problem of how to inject a service in a class that has to be instantiated not application wide but in the business logic.

He creates an example that shows a not-so-good place to use dependency injection and offers a solution - a factory that creates the objects as they're needed instead of having them floating around when they're not needed. He also talks about the difference between two types of business objects to consider in dependency injection: entities and services (hint: one depends on the other).

0 comments voice your opinion now!
newable injectable factory entity service


blog comments powered by Disqus

Similar Posts

Acim.net: Trait injection in Zend Framework 2

DevShed: Using Abstract Factory Classes in PHP 5 to Work with Online Forms

Pádraic Brady's Blog: Complex Views with the Zend Framework - Part 4: The View Factory

DevBuilder: Building XML Web Services with PHP NuSOAP

IBM developerWorks: Service Component Architecture v0.1.0 (alpha) released


Community Events

Don't see your event here?
Let us know!


api framework testing application opinion introduction project list example composer yii2 series language symfony interview podcast php7 community laravel part2

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework