Monkey-Patching

dead-metaphor Social BehaviorSoftware Programs

Categories: software-engineering

What It Brings

A mischievous monkey tampering with things it does not own — reaching into a running system and changing code at runtime, typically modifying classes or modules defined by someone else. The metaphor makes the act feel transgressive, playful, and slightly dangerous, which is exactly the engineering consensus about the practice.

Key structural parallels:

Where It Breaks

Expressions

Origin Story

The term appears to originate in the Python community in the early 2000s, though the practice itself is as old as dynamic languages. The most widely cited etymology traces it from “guerrilla patching” (patching code aggressively, without official sanction) through “gorilla patching” (a homophone confusion) to “monkey patching” (a softer, funnier animal). Patrick Ewing is sometimes credited with popularizing the term through discussions of runtime modification in Python.

In Ruby, the practice was elevated to a language feature through open classes, and Matz (Yukihiro Matsumoto) later introduced “refinements” as a scoped alternative, acknowledging that unscoped monkey-patching had become a maintenance problem. In JavaScript, the polyfill pattern — adding missing methods to built-in prototypes — is monkey-patching by another name, though the community rarely uses the term.

References

Related Mappings