[…] To the point that smart, experienced hackers reach for a monkey patch as their tool of first resort, even when a simpler, more traditional solution is possible.I don?t believe this situation to be sustainable. Where I work, we are already seeing subtle, difficult-to-debug problems crop up as the result of monkey patching in plugins. Patches interact in unpredictable, combinatoric ways. And by their nature, bugs caused by monkey patches are more difficult to track down than those introduced by more traditional classes and methods. As just one example: on one project, it was a known caveat that we could not rely on class inheritable attributes as provided by ActiveSupport. No one knew why. Every Model we wrote had to use awkward workarounds. Eventually we tracked it down in a plugin that generated admin consoles. It was overwriting
Class.inherited(). It took us months to find this out.
Eu acho que monkey patching é algo abusado em Ruby. O problema é que o esquema de bindings em Ruby é muito ruim, você não tem como criar blocos de escopo arbitrários ou fazer como em Scala e limitar o escopo de um patch. Eu já tive problemas sérios com 1.minute e conflito entre patches.




