News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Chris Hartjes' Blog:
Monkey-patching Is for Closers
July 16, 2012 @ 09:09:51

In this new post to his blog Chris Hartjes looks at why "monkey patching is for closers" - how it should be avoided in favor of making the code itself more testable rather than "hack" with the patching.

The use of monkey-patching is extremely prevalent in the Ruby community and also to a certain extent in Python usage. I'm not going to go into length about their use of it except to say that it seems quite common and I think most developers are using it as a shortcut to counter what might be poor code architecture decisions.

He includes some example code, excerpted from a blogging system where runkit was originally use to test its functionally. He shows how some simple refactoring (adding input parameters, replacing a static method call, etc) makes it easier to unit test. Comments to the post include further refactoring ideas as well as a response from the original "offender" whose post sparked Chris' response.

0 comments voice your opinion now!
monkey patch modify runkit unittest refactor


blog comments powered by Disqus

Similar Posts

Suspekt Blog: Suhosin Patch 0.9.8 for PHP 5.3.0 *BETA* - Please Test

Sebastian Bergmann's Blog: Xdebug Performance Boost

HowTo Forge: How To Harden PHP5 With Suhosin On Fedora 7

NetTuts.com: Refactoring Legacy Code: Part 6 - Attacking Complex Methods

Codeception: Codeception released with CodeCoverage support


Community Events

Don't see your event here?
Let us know!


laravel extension conference language podcast opinion introduction development laravel5 framework api community voicesoftheelephpant library interview release unittest series video psr7

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework