Metaobject
A metaobject is an object that acts on other objects. The object it works with is called the base object. A metaobject can describe or change the base object’s type, interface, methods, and attributes, or even influence how the base object behaves.
This idea is a form of reflection: a program can look at and modify its own structure while it is running. A metaobject protocol (MOP) is the set of rules and vocabulary that lets programs access and change the structure and behavior of objects.
MOPs give powerful capabilities. They can let you redefine how objects are created or how they work, not just use them as they are. But this goes against the open/closed principle, which says software should be open to new features but closed to changing existing code. MOPs expose internal details and encourage changes from within the system, which can make things unstable or hard to predict.
Because of their power and potential complexity, MOPs are usually used only in specialized tasks, such as programs that transform other software or analyze it at a deep level (reverse engineering). When there is no run-time compilation, changing the class structure can also create mismatches with code built for different models, so some languages handle these issues at compile time (as with OpenC++).
The Semantic Web uses a more dynamic object model, with classifiers that can validate evolving class relations. The first MOP appeared in Smalltalk, followed by Common Lisp’s CLOS, which added features like multiple inheritance and multimethods via generic functions.
A key book on the subject is The Art of the Metaobject Protocol. MOPs are common in software engineering tools and are one way to implement aspect-oriented programming (AOP). Early advocates like Gregor Kiczales helped promote AOP and even designed AspectJ for Java, a language that doesn’t have a built-in MOP.
This page was last edited on 2 February 2026, at 17:20 (CET).