I don't disagree that it can be misread. Anything can be misread. If you are used to mutators that return the object they mutate, then there is nothing confusing about it. If you are not used to that style then it is confusing. That is no different than other styles. With any style different from your own you will have to learn it. Saying that you don't read it correctly because you don't use that style doesn't mean the style is bad.

There are however some reasons that style is bad. Mostly it makes it difficult to catch errors if those methods fail. A simple although not elegant solution to that would be to store an error code or message in the object when an error occurs. I'm not recommending that or this style. I just think a post saying this style is bad should include more critism than "I don't like it." and "it's hard for me to read" (not exact quotes, just the feeling i get.)

If that is not how I should read your argument than I would appreciate a better explanation of why its bad. If not for myself then for others who read this node. Like I said, I don't think this is the best style all around but there are cases where it is usefull.

Your entire post is predicated on a simple straw man argument. You claim that Aristotle is against method chaining because he isn't "used to" it. Frankly, I think that's condescending and silly, but it's also wrong. The argument isn't that it's hard to "get used to," but that even if you are intimately familiar with it, it's hard to understand code that uses it. Take this code example:

The first requires a lot more effort to decipher than the 2nd. If you're not familiar with the methods and their return values in the 1st snippet, you'd have to look them up in the documentation. Even if you knew the method return values off the top of your head, you'd have to trace the chain carefully to make sure you understand what's going on.

In the 2nd, if you didn't know the return values, you could take a reasonable guess, and probably be right. And if you did know the return values, then it's obvious what's going on without any thought required at all. This is called self documenting code, and it's generally something we strive for.

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.

You missed one giant and important point. If you are familar with the style then its not more difficult to decipher.

It is more difficult to decipher, because it's ambiguous. The ambiguity must be resolved somehow. In the first example, you have to follow the chain of methods and know what type of thing they return. In the 2nd example, the variable name and usage is a big clue that helps resolve the ambiguity.

My point all along has been that it is only hard to read if you aren't used to the style.

It's not more difficult to read, it's more difficult to understand.

Frankly, I' amused you think that's condescending

I say your view is condescending, because rather than accept the fact that someone understands a concept that they don't like, you instead decided they must not understand it fully.

Understanding how method chaining works is easy. Reading code that uses method chaining is not any more difficult than other types of operator or function chaining. The difficulty comes in when you don't know whether a method is returning the object it's working on, or a sub object.