News Feed
Sections




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

Paul Jones:
Quicker, Easier, More Seductive How To Tell A DI Container From A Service Locator
December 17, 2013 @ 13:55:11

Paul Jones has continued his posts about dependency injection containers versus service locators in his site with this new post that hopes to make it easier for you to tell the difference between the two.

It is easy to confuse a Dependency Injection container with a Service Locator. They are very similar to each other. The differences are subtle. Indeed, it's even possible to use a Dependency Injection container as a Service Locator, although I think it's difficult to use a Service Locator as a Dependency Injection container. They are both sub-patterns of a more generic pattern called Inversion of Control, and some people confuse the term Dependency Injection with the more generic term Inversion of Control.

He starts off with a few questions you can ask to see which camp the implementation belongs in, mostly revolving around how the objects are fetched. He includes some code samples to help reinforce the point, showing both a service locator and DIC. He's also done some looking around at some of the major DIC implementations and which of the two he sees them as (with a few notes explaining his thoughts).

0 comments voice your opinion now!
service locator dependency injection compare inversionofcontrol

Link: http://paul-m-jones.com/archives/5843

blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Quick Start Symfony DI (Dependency Injection) Tutorial

Gonzalo Ayuso: Handling several DBALs in Symfony2 through the Dependency Injection with PHP

Jani Hartikainen's Blog: Wicket from the point of view of a PHP developer

SitePoint PHP Blog: Message Queues: Comparing Beanstalkd, IronMQ and Amazon SQS

Rob Allen: Accessing services in Slim 3


Community Events

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


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

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