News Feed
Sections




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

Pim Elshoff's Blog:
Dependency management
February 14, 2012 @ 12:04:18

Pim Elshoff has a recent post to his blog about dependency injection in PHP applications and some of the good and bad things about implementing it. He includes examples of a few different types of "injection" ranging from using globals to an actual dependency injection container.

This article describes common pains and symptoms of bad dependency management and common techniques for dealing with project-wide dependencies. [...] For the purpose of this article I am talking about classes using other classes. To manage your softwares dependencies then becomes designing your software architecture such that the depencies are good. The following sections will talk about what's bad, with good being the absense of bad.

In his "problems" section he includes things like "it's easy to do wrong", "it's hard to get rid of", the "low rate of reuse in bad DI" and how bad DI can make for "untestable software". He points to a few packages (including PHP_Depend) that can be used to determine your dependency levels. His methods for "injection" include using the global scope (so bad), using injection in a constructor/setter, making a service locator (registry) and using a full-blown dependency injection container.

All techniques, tricks and gimmicks aside, managing dependencies is more about actual design than abstract design patterns. You yourself are responsible for keeping the number of dependencies as low as possible and designing your system such that access to dependencies is provided in a sane, understandable manner.
0 comments voice your opinion now!
dependency management injection bad technique architecture


blog comments powered by Disqus

Similar Posts

Nay Pryce's Blog: "Dependency Injection" Considered Harmful

Stoyan Stefanov's Blog: Best open-source PHP CMS 2008

Kevin Schroeder's Blog: ZF2 Dependency Injection: Managing Configuration - Part 2

Gonzalo Ayuso's Blog: Building a simple SQL wrapper with PHP

Nurul Ferdous' Blog: Here is my 2 cents on Doctrine (ORM)


Community Events





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


bugfix symfony podcast install laravel voicesoftheelephpant language api package tips list interview release introduction opinion community library framework deployment series

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