<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Sometimes you just gotta monkeypatch&#8230;</title>
	<atom:link href="http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/feed/" rel="self" type="application/rss+xml" />
	<link>http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/</link>
	<description>Thinking about programming in new ways</description>
	<lastBuildDate>Tue, 15 Mar 2011 02:30:01 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Kevin Teague</title>
		<link>http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-126268</link>
		<dc:creator>Kevin Teague</dc:creator>
		<pubDate>Fri, 01 Feb 2008 01:58:58 +0000</pubDate>
		<guid isPermaLink="false">http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-126268</guid>
		<description>My definition of monkey patching is that it&#039;s just a patch applied at runtime, with the emphasis on &quot;patch&quot; as defined in The Jargon File as &quot;A temporary addition to a piece of code, usually as a quick-and-dirty remedy to an existing bug or misfeature.&quot;

http://www.catb.org/esr/jargon/html/P/patch.html

Of course, that&#039;s just my own understanding of monkey patching, lots of people have been using the term to mean dynamic modification to classes at runtime with other intents than as a patch. But two definitions of the term leaves it open for folks to get upset for no good reason though. If I say, &quot;monkey patching is good for quick and dirty fixes&quot; and I mean monkey patch *only* as &quot;patch&quot;, and someone else hears that and understands monkey patching to mean any type of dynamic class modification, then it sounds like I am saying, &quot;dynamic class modification is only useful as a guick and dirty fix&quot; - which isn&#039;t true :(

Take your example of faking out code for testing purposes. I may well find this to be an elegant, concise solution to your testing problem. But should it be called monkey patching if it&#039;s intent is as a permanent solution?</description>
		<content:encoded><![CDATA[<p>My definition of monkey patching is that it&#8217;s just a patch applied at runtime, with the emphasis on &#8220;patch&#8221; as defined in The Jargon File as &#8220;A temporary addition to a piece of code, usually as a quick-and-dirty remedy to an existing bug or misfeature.&#8221;</p>
<p><a href="http://www.catb.org/esr/jargon/html/P/patch.html" rel="nofollow">http://www.catb.org/esr/jargon/html/P/patch.html</a></p>
<p>Of course, that&#8217;s just my own understanding of monkey patching, lots of people have been using the term to mean dynamic modification to classes at runtime with other intents than as a patch. But two definitions of the term leaves it open for folks to get upset for no good reason though. If I say, &#8220;monkey patching is good for quick and dirty fixes&#8221; and I mean monkey patch *only* as &#8220;patch&#8221;, and someone else hears that and understands monkey patching to mean any type of dynamic class modification, then it sounds like I am saying, &#8220;dynamic class modification is only useful as a guick and dirty fix&#8221; &#8211; which isn&#8217;t true :(</p>
<p>Take your example of faking out code for testing purposes. I may well find this to be an elegant, concise solution to your testing problem. But should it be called monkey patching if it&#8217;s intent is as a permanent solution?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Ramm</title>
		<link>http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-126089</link>
		<dc:creator>Mark Ramm</dc:creator>
		<pubDate>Thu, 31 Jan 2008 13:01:58 +0000</pubDate>
		<guid isPermaLink="false">http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-126089</guid>
		<description>Thanks Kevin, 

I would just like to add that there even gorilla patching has it&#039;s uses.   I fake out bits of SQLAlchemy during testing sometimes, and I&#039;ve got a mokeypatched cherrypy wsgi server that we delivered to a client on a very tight deadline, and very specific requirements. 

And you are right to say that Inversion of Controll and Dependency Injection don&#039;t require monkeypatching and are therefore totally seprate ideas -- but they do provide use-cases for dynamically monkeying around with classes.   I was not at all clear about that.   ;)</description>
		<content:encoded><![CDATA[<p>Thanks Kevin, </p>
<p>I would just like to add that there even gorilla patching has it&#8217;s uses.   I fake out bits of SQLAlchemy during testing sometimes, and I&#8217;ve got a mokeypatched cherrypy wsgi server that we delivered to a client on a very tight deadline, and very specific requirements. </p>
<p>And you are right to say that Inversion of Controll and Dependency Injection don&#8217;t require monkeypatching and are therefore totally seprate ideas &#8212; but they do provide use-cases for dynamically monkeying around with classes.   I was not at all clear about that.   ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kevin Teague</title>
		<link>http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-126020</link>
		<dc:creator>Kevin Teague</dc:creator>
		<pubDate>Thu, 31 Jan 2008 07:22:21 +0000</pubDate>
		<guid isPermaLink="false">http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-126020</guid>
		<description>Monkey Patch was meant to be a &quot;less forceful&quot; sounding term than Guerilla Patch (misheard as Gorilla Patch). Guerilla patches are modifications made to your framework or library code without your knowledge by another add-on product. The metaphor being you install someone&#039;s add-on product to your application and that add-on has changed some framework behaviour to make their code work. This breaks your own code - hence the modifications to the behaviour that you were relying on has been changed against your knowledge - guerilla warfare in code.

Considering that this term originated from Zope, which embraced magic such as acquisition, casual monkey patching is considered harmful, while other forms of metaprogramming and dynamic trickery were not (at least back in the 90&#039;s and early 2000&#039;s, Zope has mostly moved to an explicit is better than implicit attitude). Monkey patches are a good way of expressing, &quot;we should change this framework code, try it out in your sandboxes before we include it in trunk and see if it causes any problems.&quot;

Plone&#039;s Archetypes for example generates methods dynamically based on a schema declaration, but this is never referred to as monkey patching.

Inversion of Control is something that is common to almost all frameworks, it sounds rather fancy but it just means that some portion of the control flow of your application is handled by library or framework code. As Martin Fowler explains, even simple libraries such as Tk perform Inversion of Control (http://martinfowler.com/bliki/InversionOfControl.html).  Dependency injection is more specific form of Inversion of Control where the control flow that is being handled by the framework is how pluggable/swapable implementations are being chosen. Dependency Injection can be defined as, &quot;the implementation of one class is performed partially by object(s) supplied by the framework&quot;.</description>
		<content:encoded><![CDATA[<p>Monkey Patch was meant to be a &#8220;less forceful&#8221; sounding term than Guerilla Patch (misheard as Gorilla Patch). Guerilla patches are modifications made to your framework or library code without your knowledge by another add-on product. The metaphor being you install someone&#8217;s add-on product to your application and that add-on has changed some framework behaviour to make their code work. This breaks your own code &#8211; hence the modifications to the behaviour that you were relying on has been changed against your knowledge &#8211; guerilla warfare in code.</p>
<p>Considering that this term originated from Zope, which embraced magic such as acquisition, casual monkey patching is considered harmful, while other forms of metaprogramming and dynamic trickery were not (at least back in the 90&#8242;s and early 2000&#8242;s, Zope has mostly moved to an explicit is better than implicit attitude). Monkey patches are a good way of expressing, &#8220;we should change this framework code, try it out in your sandboxes before we include it in trunk and see if it causes any problems.&#8221;</p>
<p>Plone&#8217;s Archetypes for example generates methods dynamically based on a schema declaration, but this is never referred to as monkey patching.</p>
<p>Inversion of Control is something that is common to almost all frameworks, it sounds rather fancy but it just means that some portion of the control flow of your application is handled by library or framework code. As Martin Fowler explains, even simple libraries such as Tk perform Inversion of Control (<a href="http://martinfowler.com/bliki/InversionOfControl.html" rel="nofollow">http://martinfowler.com/bliki/InversionOfControl.html</a>).  Dependency injection is more specific form of Inversion of Control where the control flow that is being handled by the framework is how pluggable/swapable implementations are being chosen. Dependency Injection can be defined as, &#8220;the implementation of one class is performed partially by object(s) supplied by the framework&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Ramm</title>
		<link>http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-125885</link>
		<dc:creator>Mark Ramm</dc:creator>
		<pubDate>Wed, 30 Jan 2008 21:40:50 +0000</pubDate>
		<guid isPermaLink="false">http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-125885</guid>
		<description>Yea, in other languages they call monkeypatching open classes, or label the things we can do with monkey patching &quot;inversion of control&quot; and generally think that these meta-programming kinds of things are cool.   

And they are.   They are useful tools.   Python has a bit of nasty monkey-in-the-mouth taste from bad monkeypatching experiences which were hard to understand and debug.  And there is some truth to that.   Metaprogramming in general can make debugging more interesting.   

If we still built housed out of straw and mud, home repairs would be super cheep and easy too.  But, me I&#039;m still gonna use my low flow toilets, insulated walls, electric wiring, and polyvinyl siding, even though those things are more difficult to debug and more expensive to replace. 

My point, is that in software, as everywhere else, it&#039;s all about trade-offs.</description>
		<content:encoded><![CDATA[<p>Yea, in other languages they call monkeypatching open classes, or label the things we can do with monkey patching &#8220;inversion of control&#8221; and generally think that these meta-programming kinds of things are cool.   </p>
<p>And they are.   They are useful tools.   Python has a bit of nasty monkey-in-the-mouth taste from bad monkeypatching experiences which were hard to understand and debug.  And there is some truth to that.   Metaprogramming in general can make debugging more interesting.   </p>
<p>If we still built housed out of straw and mud, home repairs would be super cheep and easy too.  But, me I&#8217;m still gonna use my low flow toilets, insulated walls, electric wiring, and polyvinyl siding, even though those things are more difficult to debug and more expensive to replace. </p>
<p>My point, is that in software, as everywhere else, it&#8217;s all about trade-offs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Brewer</title>
		<link>http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-125757</link>
		<dc:creator>Robert Brewer</dc:creator>
		<pubDate>Wed, 30 Jan 2008 15:16:07 +0000</pubDate>
		<guid isPermaLink="false">http://compoundthinking.com/blog/index.php/2008/01/30/sometimes-you-just-gotta-monkeypatch/#comment-125757</guid>
		<description>Meh. Just stick a docstring or comment on it saying, &quot;Please replace this&quot;, and all of a sudden you&#039;re doing sexy Dependency Injection and Inversion of Control instead of evil monkeypatching.</description>
		<content:encoded><![CDATA[<p>Meh. Just stick a docstring or comment on it saying, &#8220;Please replace this&#8221;, and all of a sudden you&#8217;re doing sexy Dependency Injection and Inversion of Control instead of evil monkeypatching.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

