News Feed
Sections




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

Tim's Blog:
Cyclic Dependency Injection and Making a Choice
July 27, 2012 @ 08:09:53

In this recent post Tim shares a time when he came across a case of "cyclic dependency injection" and how he handled it.

Cyclic dependency injection is your code asking you to make a choice rather than remain on the fence. Here's a story of what happened in my case. I ran across a troubling case of cyclic dependency injection in the constructors of some code.

In his example, one object takes in another injected as a parameter to a method. The second object then takes in an instance of the first object as a parameter to one of its methods, the circular dependency. He shares both the original code that was performing this dependency issue as well as the refactored code showing his solution (hint: moving functionality around can be a good thing).

0 comments voice your opinion now!
cyclic dependency injection refactor example


blog comments powered by Disqus

Similar Posts

Developer Tutorials Blog: Easy Screen Scraping in PHP with the Simple HTML DOM Library

FrSIRT: Vivvo Article Management CMS SQL Injection and PHP File Inclusion Vulnerabilities

Zend Developer Zone: Quick Start Symfony DI (Dependency Injection) Tutorial

KillerPHP.com: What is Refactoring PHP Code?

Mike Bernat's Blog: Installing Xdebug - Best Decision You Will Ever Make


Community Events





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


list framework tool introduction security artisanfiles composer voicesoftheelephpant community conference opinion laravel series language interview version library podcast symfony release

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