News Feed
Sections




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

Architexa Blog:
Simplifying Dependency Injection
April 19, 2010 @ 12:58:15

Dependency injection is becoming a more and more popular topic among developers, but for someone just starting out with it, a lot of the sites out there explaining it can be confusing. On the Architexa blog there's a dead simple explanation of DI and what it's good for (warning: it's not a PHP example, but it translates over).

DI is fairly simple - its main goal is the removal of a class dependency from some code. This class dependency is then 'injected' into the code where it is needed. Using dependency injection helps in code maintenance, re-usability, testability, and improves code readability.

A code example is included of a User class that is responsible for making "users" and including all of the needed information and functionality to go with it in a self-contained object. They also mention some of the benefits that come along with it and the complications that could come from its use.

0 comments voice your opinion now!
dependency injection simple introduction


blog comments powered by Disqus

Similar Posts

Lars Strojny's Blog: Dependency Injection Container Refactorings, Part Two

PHPEasy.co.uk: Object Orientation Basics part 4 Implementing CRUD methods

Gareth Heyes' Blog: htmlentities is badly designed

PHPit.net: PHP on the command line

Padraic Brady's Blog: Zend Framework: Surviving The Deep End Book - Chapters 4, 5, 6, 7 and Appendix


Community Events





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


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

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