http://qs321.pair.com?node_id=11137391


in reply to Re^2: OO Pattern Container x Elements and Method Chaining (House, Person, Inhabitant)
in thread OO Pattern Container x Elements and Method Chaining

as I said, there is legacy code which is using Method Chaining (I didn't design it)

$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

UPDATE

regarding your suggestion, see Re^3: OO Pattern Container x Elements and Method Chaining