News Feed
Jobs Feed
Sections




News Archive
Evert Pot's Blog:
Dangers of mutual dependencies
March 06, 2009 @ 13:42:40

In a recent post to his blog Evert Pot warns against some of the issues that mutual dependencies in your applications.

Much like most people, I try work out my class dependencies through a top-down 'waterfall'-ish approach. By attempting this, I think allows me to keep the structure very clear and understandable. [...] I try to apply the same model to instantiated objects and packages (groups of classes). When an object encapsulates another object, I attempt to make sure the sub-object object is not aware of the parent. When I design packages, I attempt to make sure 2 packages don't require 'each other'.

He gives an example of where this could cause problems - a Database logger that has three types of logging included: file, syslog and database. Obviously the last of the three requires the Database class so they must always be used/included together.

As a bonus a database-error could occur while logging, resulting in an endless loop (or segmentation fault if you're using PHP). [...] However, these types of situations are sometimes simply unavoidable (that's why we have include_once). When they are needed, they should be implemented with care and consideration.
0 comments voice your opinion now!
mutual dependencies dependent class database log example


blog comments powered by Disqus

Similar Posts

Community News: phpMyAdmin 2.10.2 Released

Jacob Santos' Blog: Why SDO Doesn't Take Off

Zend Developer Zone: Did you hear Sun was buying MySQL?

Evolt.org: Failover Database Connection with PHP + mySQL

Bit-Tech.net Formus: PHP "raycaster" 3D renderer


Community Events











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


example composer code opinion development framework api unittest functional phpunit testing series release interview introduction community database podcast zendframework2 language

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