[Zope3-dev] zwiki: performance of findChildren()

Max M maxm@mxm.dk
Wed, 30 Apr 2003 21:35:04 +0200


Chris Withers wrote:

> Max M wrote:
>
>> Why put the relation in the object?
>
> ...becasue it's much more natural to work that way. 


Not for me.

>> Isn't it better to have a container with different relations?
>
> If you wanted to know what someone was working on, would you ask them 
> or ask their mother?



If an object needs to be related to another object, there is no need for 
any of the objects to know they are related. If all the relations are 
external to the objects you can relate objects that are not programmed 
to be related. Keeping all the relation code loosely coupled from the 
objects.

Making the objects hold the responsibility for the relations means that 
all objects has to take it into account. There is no reason for that. To 
take a simplified example from Plone.

relations/
    members_groups

Members/
Groups/

In this case I can make the "members_groups" relationship manager take 
care of the relations, and Members and Groups would not need to know 
they can be related. I don't have to change the code in Members at all. 
Thus leaving Plone as it is, while I can add group functionality.

maxm_groups = context.relations.member_groups.get(context.Members.maxm)

The other way around I would need to change the Member product, adding 
group relations, and I can risk all hell breaking loose when Plone is 
updated the next time.


regards Max M