[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: What does 'Monkey Patching' exactly Mean in Ruby?
From:       marc <gmane () auxbuss ! com>
Date:       2008-12-28 12:06:59
Message-ID: MPG.23c18a5742806a48989b8b () news ! gmane ! org
[Download RAW message or body]

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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic