Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^5: OO Pattern Container x Elements and Method Chaining

by jdporter (Paladin)
on Oct 13, 2021 at 03:53 UTC ( [id://11137462]=note: print w/replies, xml ) Need Help??


in reply to Re^4: OO Pattern Container x Elements and Method Chaining
in thread OO Pattern Container x Elements and Method Chaining

yes, sure, that's all cool.... but I don't believe that has any bearing on method chaining.

  • Comment on Re^5: OO Pattern Container x Elements and Method Chaining

Replies are listed 'Best First'.
Re^6: OO Pattern Container x Elements and Method Chaining
by LanX (Saint) on Oct 13, 2021 at 11:42 UTC
    For instance see https://atomicobject.com/resources/oo-programming/other-oo-class-relationships

      Association implies symmetry; both classes know each other and can message each other.

      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

    update

    a 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
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11137462]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (3)
As of 2024-04-19 22:10 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found