From: Ashley Moran Date: 2006-12-06T07:41:42+09:00 Subject: Re: "more than enough rope" 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. Ashley