News Feed
Sections




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

PHPMaster.com:
An Introduction to Dependency Injection, Service Locators & Factories (Part 1)
June 21, 2012 @ 08:59:15

On PHPMaster.com they've posted the first part of a series looking at something that's become a hot topic in the PHP community over the last months - dependency management and service locators.

From a programmer's perspective, the process of designing easily consumable APIs while still keeping a decent level of decoupling between the involved classes is always a tricky trade-off, as the more expressive the dependencies are, the harder the work is that needs to be done behind the scenes for wiring up the collaborators in their proper sequence.

In this two-part series I'll be doing a quick roundup of some of the most common methodologies that can be employed for managing class dependencies in modern application development, ranging from using service locators and injectable factories, to sinking your teeth into plain vanilla Dependency Injection, and even implementing a naive Dependency Injection Container.

He talks about the "plague of the 'new' operators" and how, through the use of an injected factory object, they could be easily replaced. Code samples are included showing the initial state and the end result, refactored to inject his "SerializerFactoryInterface" into the "FileStorage" class.

0 comments voice your opinion now!
dependency injection service locator factory tutorial series


blog comments powered by Disqus

Similar Posts

PHPit.net: An Introduction to the Winbinder Library (Part 1)

Alan Knowles' Blog: Getting Started with HTML_FlexyFramework, DataObjects and HTML_Template_Flexy

PHPBuilder.com: Developing a Ajax-driven Shopping Cart with PHP and Prototype

DevShed: Performing Basic Tasks with MySQL 4.1 and Above, using mysqli with PHP 5

Anthony Ferrara: Object Scoping: A Triste Against Service Containers


Community Events





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


version composer package series podcast install framework opinion interview community introduction release laravel application voicesoftheelephpant symfony update language security library

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