[rspec-users] class << self considered harmful... really?

Mark Wilden mark at mwilden.com
Wed Nov 26 10:00:34 EST 2008

On Wed, Nov 26, 2008 at 6:51 AM, Matt Wynne <matt at mattwynne.net> wrote:

> That's one of the things that attracted me to using class << self to
> contain all these methods - it just seemed easier to me to visualise what
> was going on.

That makes sense. If you're doing things where being inside the eigenclass
helps, then by all means open the eigenclass. I think I and others were just
commenting on it being a default style for some programmers (and I went on
to snarkily speculate on some of their motives).

I'd be really interested to know the nature of the criticisms made about it
> in the Matz book Mark mentioned.

I'll have a peep when I get in to work today. Of course, it's hard to tell
what are Matz's opinions and what are Flanagan's (who's not a major light in
the Ruby world, by any means). Basically, I think his/their objections were
the ones I've used: it's just not necessary in most cases. It's also
different from the way class methods are defined in C++, Java, and C#. But
sometimes it's useful.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081126/d287c1ec/attachment.html>

More information about the rspec-users mailing list