From: Eric Mahurin Date: 2008-02-27T23:38:35+09:00 Subject: Re: Monkeypatching is Destroying Ruby ------=_Part_1788_18747187.1204123116790 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, Feb 27, 2008 at 7:46 AM, James Gray wrote: > On Feb 24, 2008, at 10:02 PM, James Gray wrote: > > > On Feb 23, 2008, at 4:23 PM, Eric Mahurin wrote: > > > >> I usually only do monkey patching in the > >> following cases which have no reuse: top-level script, testing, and > >> quick hacking. > > > > I think it's the ideal tool for adding compatibility methods. > > Along these lines, I read a chapter in Design Patterns in Ruby last > night that suggests using Ruby's open classes as one possible way to > implement the Adapter pattern. The book includes a pretty good > discussion of the plusses and minus to this approach and makes > recommendations about when it's probably worth the trade-off. It's a > good read. > > James Edward Gray II I don't have the book. I wouldn't mind seeing the +/- list. You are talking about this, right? http://en.wikipedia.org/wiki/Adapter_pattern Using what this link above suggests (adapter "has-a" or "is-a" adaptee) is the better way to go, IMO. There are multiple ways to do this in Ruby. Monkey-patching/open-classes makes the solution: adapter IS adaptee. I don't know if you can even call it the adapter pattern since you are destroying the adaptee interface. ------=_Part_1788_18747187.1204123116790--