Perl: the Markov chain saw | |
PerlMonks |
Re^6: OO Pattern Container x Elements and Method Chainingby LanX (Saint) |
on Oct 13, 2021 at 11:42 UTC ( [id://11137474]=note: print w/replies, xml ) | Need Help?? |
For instance see https://atomicobject.com/resources/oo-programming/other-oo-class-relationships
A Product class object may need to know the last sale that it was involved with. We could put a pointer to a Sale class object inside the private part of Product. A Sale class object may need to know all of the Products involved with the Sale. We can put a pointer to a pointer (double pointer) in Sale that will let us store zero or more Products associated with a Sale. hence this is not uncommon $stock->product("Book")->lastSale()->undo() and affects both objects
updatea maybe better example I found is the part_of association of Apartment <-> Room A $room can only belong to one containing $apartment and has a (weakened) back-reference Like this if $room->burns() than $apartment->burns() > but I don't believe that has any bearing on method chaining. $street->apartment("5a")->room("living")->burns() HTH! :)
Cheers Rolf
In Section
Seekers of Perl Wisdom
|
|