|Pathologically Eclectic Rubbish Lister|
Re^3: chaining method callsby adrianh (Chancellor)
|on Jun 12, 2003 at 09:53 UTC||Need Help??|
My opinion is that cascading is an idiom that doesn't translate well into Perl. Without a special syntax to designate a cascade, a simulated cascade is indistinguishable from a gross violation of the Law of Demeter.
That's an interesting point, and the most convincing one I've come across against the idiom. I can see how a maintainence coder might see a cascade and have it look like a ghastly exposure of internals ripe for refactoring.
That said, it's not a problem I've ever come across. Probably because that by the time you're looking at the code you already have an idea of what methods are associated with what objects, so you can mentally parse out cascades from other code.
The fact that I try not to write objects that flagrently violate the LoD probably helps too :-)
(I wonder if Perl6 will have an explicit syntax? If not we could always make one up.)
I still find:
clear, and preferable to:
To me the former is succinct and obscures the mainline less. Probably too much Smalltalk at an early age :-)