$house->get_member("Willy)->clean_house();
Now the model changed and Person "Willy" can be member of different households
> I have never actually run into a case where an element needed to know its container
I have no idea how method chaining would be implemented else, since ->clean_house() is referring to $house
In the new model case ->get_member() can't return a Person object anymore
One possibility discussed here is to return a Wrapper-Object Inhabitant ° which wraps the relation
'Person ->belongs_ to-> House'
and delegates accordingly.
Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery
°) update s/Member/Inhabitant/ for consistency to previous posts
regarding your suggestion, see Re^3: OO Pattern Container x Elements and Method Chaining
In reply to Re^3: OO Pattern Container x Elements and Method Chaining (House, Person, Inhabitant)
by LanX
in thread OO Pattern Container x Elements and Method Chaining
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |