From: marc Date: 2008-12-28T21:06:59+09:00 Subject: Re: What does 'Monkey Patching' exactly Mean in Ruby? David A. Black said... > Hi -- > > On Sun, 28 Dec 2008, marc wrote: > > > David A. Black said... > >> Hi -- > >> > >> On Sun, 28 Dec 2008, Yaser Sulaiman wrote: > >> > >>> According to Wikipedia, a monkey patch[1] is: > >>> > >>>> a way to extend or modify the runtime code of dynamic languages [...] > >>>> without altering the original source code. > >>> > >>> The following statement from the same entry confused me: > >>> > >>>> In Ruby, the term monkey patch was misunderstood to mean any dynamic > >>>> modification to a class and is often used as a synonym for dynamically > >>>> modifying any class at runtime. > >>> > >>> I would like to know the exact meaning of monkey patching in Ruby. > >> > >> There's no exact meaning. Some people use it to mean re-opening core > >> classes; some people use it to mean re-opening core classes in an > >> incompetent, unsafe manner; some people use it as a way of indicating > >> that any time you re-open a core class, you shouldn't (which is a > >> well-intentioned but reductive position); some people use it to mean > >> re-opening non-core classes; and so on. > > > > My brain is fuddled today recovering from flu, but what do you mean by > > "reopening"? > > Like this: > > class Array > def my_new_method > end > end > > where I'm reopening the core Array class and adding and/or overriding > methods in it. Okay, so reopening is extending or overriding (a method of) a core class. Good to know the lingo. And I concur with your earlier assertion regarding the MP term: It's basically a negative, uninformative, rather silly term that has nothing going for it. -- Cheers, Marc