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

Jakub Zalas' Blog: Managing object creation in PHP with the Symfony2 Dependency Injection component

Reddit.com: Should I be doing just about everything using REST?

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

Stefan Esser\'s Blog: DokuWiki remote PHP code injection

Artur Ejsmont's Blog: How to structure a Zend Framework application and it's dependencies


Community Events





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


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

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