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.
Chaining vs. Cascading (Score:2, Insightful)
Without first-class support for cascading, a simulated cascade (i.e., a chain) is hard to distinguish from a gross violation of the Law of Demeter.
Re:Chaining vs. Cascading (Score:2)
I don't really want to try and describe this in Smalltalk terms. This isn't Smalltalk and shouldn't be viewed as such. Even though the idea appears to come from Smalltalk, it's simply not the same thing as a cascade. That seems like saying for (@array) shouldn't be used in Perl because it's not an OO iterator. In this case, it would not be helpful to insist on a full implementation of the GoF Iterator pattern. It's certainly an iterator, but it's implemented in a Perlish way. The case of the chained mutators in Java, we have a useful idiom being implemented in a Java-ish way, if you will.
As for violating the Law of Demeter, I just don't see it. The Law of Demeter is about decoupling your classes. Since chained mutators don't inherently rely on any other class, they don't violate said law. Perhaps you're referring to the calling code as violating that law, but if they're allowed to call the original mutator without violating the Law of Demeter, then subsequent calls, whether against the original variable or the return value don't seem to be a problem.
Maybe I just don't understand the Law of Demeter well enough. I pulled out some books to get a better understanding, but I still don't see what you're getting at. Could you explain?
Reply to This
Parent
Re:Chaining vs. Cascading (Score:1)
Violations of the Law of Demeter are characterized by chains of method calls, where the target object changes along the way as the code reaches through its friends and into their friends (and perhaps into their friend's friends). Lots of coup