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

Mark Wilden mark at mwilden.com
Thu Nov 27 19:58:48 EST 2008

On Thu, Nov 27, 2008 at 4:40 PM, Brian Takita <brian.takita at gmail.com>wrote:

> When maintaining code, I often wish I could travel back in time and
> tell the writer "Don't do that". :)

I don't see how we can solve the problem of people not following style
guidelines by giving them another style guideline to follow. :)

module methods have encapsulated state.

Probably 99% of the (non-framework) class methods I've seen have no state.

We all have seen YAGNI
> bite us in the ass too, especially when it means turning off the
> brain. I don't think 2 extra filler lines of code make that strong of
> an argument, when there is more than one class method (and even if
> there is one class method IMO).

If writing those two lines of code are unnecessary for any of the uses you
and others have described, I would call that turning off the brain. :)

> I think we also like how consistent conventions and delineation of
> responsibility make code faster to read and understand.

Agreed, but I think this begs the question under discussion.


(For those who are tired of this non-RSpec-related discussion (but
apparently find themselves forced to read it), I really will try to wrap up
my contribution. I don't have the time for the Ruby list, so this is the
only place I have to talk about fun stuff like this. ObRSpec: the discussion
did illuminate a situation where tests can pass but the development app can
fail - when using class variables in RoR.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/rspec-users/attachments/20081127/cdbfa3fe/attachment.html>

More information about the rspec-users mailing list