Information About

Monkey-patch




They are also referred to as:
  • Guerilla patch

  • Extending previously declared classes

  • Reopening classes



ONTOLOGY

The term Monkey-Patch was first used as '''Guerilla Patch''', which referred to changing Code sneakily at Runtime without any rules. In some Applications (such as Zope 2 ) these Patches would sometimes interact counter intuitively which was referred to as the Patches engaging in battle with each other.

Due to the fact that the word ''guerilla'' and ''gorilla'' sound so similar people started using the incorrect term Gorilla Patch instead of '''Guerilla Patch'''. When a Developer then created a ''Guerilla Patch'' they tried very hard to avoid any battles that may ensue due to the Patch and the term '''Monkey-Patch''' was coined to make the Patch sound less forceful.

The term Monkey-Patch caught on and has been in use ever since.


APPLICATIONS

Monkey-Patching is used to:


PITFALLS

Using a Monkey-Patch can lead to the following problems:
  • If the product you have changed, changes with a new release it may very well break your Patch .

  • If two modules attempt to Monkey-Patch the same Method , one of them (whichever one runs last) "wins" and the other Patch has no effect.

  • It creates a discrepancy between the original Source Code on Disk and the observed behaviour that can be very confusing when troubleshooting, especially for anyone other than the Monkey-Patch author.

  • A Monkey-Patch can lead to upgrade problems when the patch makes assumptions about the patched Object that are no longer true.



SEE ALSO