You missed one giant and important point. If you are familar with the style then its not more difficult to decipher.
$foo->bar(2) ->baz(3) ->qux;
Is no more difficult to read than:
my $bar = $foo->bar(2); $bar->baz(3); $bar->qux;
My point all along has been that it is only hard to read if you aren't used to the style. Map, grep and sort used to be nearly impossible for me to read because that wasn't a style I had encountered before. Now I understand and recognize those patterns. If I know that the mutators return the object in order to allow chaining then that code is easy to follow. If I don't know that then a quick check to the POD makes it clear in an instant.
The first requires a lot more effort to decipher than the 2nd.
That is only true for those who arn't used to it, or don't use it. It is not true for everyone, it is not an absolute that one is harder or easier to read. Like I said originaly, method chaining (mutators or otherwise) has always made perfect sense to me, maybe it's the way I think or experiences I've had. Either way, arguments that it's bad because it's hard to decipher, read, trace, etc, are all false because it is just a matter of the readers perception/experience.
Frankly, I' amused you think that's condescending because I think it's condescending to assume that because some people can't read it that it should be considered harmfull by everyone.
|Replies are listed 'Best First'.|
Re^6: Mutator chaining considered harmful
by revdiablo (Prior) on Dec 30, 2004 at 20:28 UTC