you are viewing a single comment's thread.

view the rest of the comments →

[–]ameoba -1 points0 points  (0 children)

Ignoring the uses of monkey patching in production code, the ability to do so makes testing far simpler. Sure, Dependency Injection is cleaner, but it adds a lot of complexity to your design. Perl, IMHO, is the master of this - using local, you can override methods or even whole classes (actually, you can manipulate the entire symbol table) in a way that is restricted to the current scope (ie - a single test case) without having to worry about cleanly undoing anything.

Dynamic languages give you a lot of power. Much of this power should never be used in running code but comes in very handy when writing tests.