[dev] Cyclic dependencies in binders

Jan Schneider jan at horde.org
Tue May 11 07:38:52 UTC 2010


Zitat von Gunnar Wrobel <p at rdus.de>:

> Quoting Jan Schneider <jan at horde.org>:
>
>> There's a problem with creating binders for objects with cyclic  
>> dependencies.
>>
>> I'm currently refactoring Horde_Alarm, and it depends on  
>> Horde_Notification if displaying alarms as notifications.  
>> Horde_Notification OTOH depends on Horde_Alarm because it triggers  
>> the alarm system before displaying notifications, so that it can  
>> push any new alarms on the stack right before.
>>
>> Theoretically I would have two binders and both use the injector to  
>> get the other object. But this obviously leads to an endless loop.
>>
>> Any ideas how to solve this?
>
> I did not look at the code now but I assume Horde_Notification needs  
> to be fixed so that it does not depend on Horde_Alarm. The problem  
> should not only exist for the binder but for packaging, too. The  
> notification system seems to be the more generic module so Alarm  
> should depend on it. But not the other way around.

It does not *depend* on it, technically. And it would be easy to  
change the binders to not attach the alarm object to the notification,  
if Horde_Alarm wasn't available.
The point is that Horde_Alarm currently requires Horde_Notification to  
trigger loading alarms from the applications. Granted, we could  
probably trigger the alarm loading differently, and now that I think  
of it, this probably makes sense because it's much clearer.
That wouldn't solve the general problem though, that some other  
injected objects might have circular dependencies in the future.

Jan.

-- 
Do you need professional PHP or Horde consulting?
http://horde.org/consulting/



More information about the dev mailing list