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

Smackdown Blog: Rackspace Hacked Clients, Check Your Databases: Wordpress "wp_optimize" Backdoor

Stuart Herbert's Blog: Introducing phix

Project: phpVirtualBox - VirtualBox Management Tool

PHPImpact Blog: Dependency Injection in Zend Framework

Aaron Wormus' Blog: PHP CMS Historical Notes


Community Events





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


list install opinion language refactor framework release introduction laravel testing unittest threedevsandamaybe code symfony2 configure interview series community developer podcast

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