Hi --

On Wed, 6 Dec 2006, Ashley Moran wrote:

>
> On Dec 05, 2006, at 10:21 pm, Giles Bowkett wrote:
>
>> I just found out that Josh Susser's cancelled presentation at RubyConf
>> was going to be called "More than enough rope to hang yourself," and
>> was going to be about how to avoid misusing Ruby's power. I've
>> definitely written code where my main goal was getting my head around
>> lambda() or things like that -- now I have code on my hands where I'm
>> trying to decide, is this beautiful, well-written stuff, or was I just
>> indulging in a bunch of gratuitous cleverness because I had the
>> option?
>> 
>> Obviously this is a judgement call -- but does anyone know good
>> resources for those questions like, when do I use metaprogramming,
>> when do I just use more normal techniques?
>
>
> I've wondered this too after I've written something that looks a bit too 
> clever for its own good.
>
> I usually ask myself these questions:
>
> - do I only think it looks too clever because I couldn't do it in Java?
> - when I come back to it 6 months later, will it be more obvious what I
> was doing than the longhand version?
> - could I factor out the cleverness into a library, or is it more of
> a design pattern?
>
> answers.should == %w[Yes] * 3  # :)
>
> If the test passes, it's probably good.  Usually, when something looks like 
> Ruby for Ruby's sake, it's because before I wrote it, I wasn't good enough to 
> understand it (never figured out how that works...).  If I feel like a better 
> programmer afterwards, it stays.

Doesn't looking like Ruby for Ruby's sake mean that it's clear,
expressive, elegant, and maintainable? :-)  Those are the
characteristics I associate with what I think of as the most
Ruby-esque Ruby code, anyway.


David

-- 
                   David A. Black | dblack / wobblini.net
Author of "Ruby for Rails"   [1] | Ruby/Rails training & consultancy [3]
DABlog (DAB's Weblog)        [2] | Co-director, Ruby Central, Inc.   [4]
[1] http://www.manning.com/black | [3] http://www.rubypowerandlight.com
[2] http://dablog.rubypal.com    | [4] http://www.rubycentral.org