NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.
All the Perl that's Practical to Extract and Report
Stories, comments, journals, and other submissions on use Perl; are Copyright 1998-2006, their respective owners.
I don't get it (Score:1)
Re:I don't get it (Score:2)
It's a question of encapsulation. Imagine that the Salesman class no longer has need of a manager accessor, but you still need to know which office the salesman is with. You might get a office method pushed into the Salesman class. Then, every place where you have the above code needs to be changed to:
If that's called a lot, it can be a maintenance nightmare.
However, what if you have this?
Then, your calling code (again, remember this example is contrived), becomes this:
At this point, if you need to change the hierarchy, you only have to alter &Customer::office instead of all of the calling code. You've properly encapsulated the hierarchical structure and greatly improved maintainability.
Reply to This
Parent
Re: (Score:1)
Re: (Score:2)
You're welcome. It's not exactly intuitive. Took me a couple of tries to get it :)
Re: (Score:1)
Thank you. I hadn’t realized Moose’s powerful delegation mechanisms we’re more than handy shortcuts. This provides an excellent use case for them.
For those who don’t know Moose every attribute object can have a handles er … attribute … so the example here can be defined like:
Re: (Score:1)