in reply to Re^8: Mutator chaining considered harmful
in thread Mutator chaining considered harmful

I would prefer that people stop using {and writing, and chaining} methods that return the object they operate on.
I would prefer having Natalie Portman as a girlfriend (having just seen Closer, the subject is fresh on my mind, sorry).

But seriously...

I find mutators-that-return-$self to be very handy. I've tried to understand your complaint. In the Alpaca book, I talk about mutators that return:

I've seen it all. All have been useful over time. The real thing is to be as consistent as you can, and don't change it once you've committed.

My File::Finder::Steps methods actually return a cloned-and-modified-$self, permitting a chaining of sorts. I find the notation very natural there. If I had to do it some other way, I'd probably scream. {grin}

So, perhaps you are not comfortable with mutators returning $self, but they're probably here to stay. My guess is that you got burned once, and now you're out for blood. Chill. {grin}

-- Randal L. Schwartz, Perl hacker
Be sure to read my standard disclaimer if this is a reply.

  • Comment on •Re^9: Mutator chaining considered harmful