From: Robert Klemme Date: 2008-02-24T18:39:55+09:00 Subject: Re: Monkeypatching is Destroying Ruby On 23.02.2008 23:36, Avdi Grimm wrote: > On Sat, Feb 23, 2008 at 5:23 PM, Eric Mahurin wrote: >> I don't agree with the title > > Like I said at the beginning of the article, neither do I ;-) > >> * adding new (or perceived missing) functionality (methods) to a class. The >> traditional solution would be to just inherit from the class and use the >> derived class instead where you want this new functionality. Since you >> can't inherit from some classes (i.e. immediates, a problem with the >> language IMHO), you can instead use something like Forwardable instead. > > Indeed. The irony here is that Ruby is perhaps the easiest language > in the world to implement delegation in. I'm planning on writing a > series of posts on alternatives to monkey patching, and delegation is > going to be one of the first techniques I talk about. But keep in mind that since it's so easy you can shoot yourself in the foot equally well as I have tried to point out in a recent post: http://groups.google.com/group/comp.lang.ruby/msg/90f76656fd2c0f68 On a broader scale: I agree with your assessment that MP can cause bugs that are hard to find and that there are usually other ways to achieve the same effect in cleaner ways. I for my part try to steer people away from using those "dirty" techniques (MP, inheriting core classes etc.) whenever I think there is a easier and clearer solution available. Do we need a discussion about this? Is MP really destroying Ruby and / or Rails? I don't know. Maybe MP is just the current buzz word that everybody uses and will go away like any other fashion. But I do think that it's helpful to once in a while step out of daily business and think about things on a broader scale. It helps keep our minds flexible and not run into a completely wrong direction for too long a time. Kind regards robert