Aspect-oriented programming using reflection and metaobject protocols

Gregory Thomas SULLIVAN · Communications of the ACM · 2001

This article focuses on aspect-oriented programming using reflection and metaobject protocols. Computational reflection enables a program to access its internal structure and behavior and also to programmatically manipulate that structure, thereby modifying its behavior. A metaobject protocol (MOP) defines execution of an application in terms of behaviors implemented by metaclasses. A MOP allows the programmer to incrementally modify the default behavior of a programming language. A MOP allows one to implement aspect code directly, without a static compilation phase. This is beneficial in several ways. Aspect behavior is more robust in the face of dynamic events such as class loading. Another benefit is that the aspect code can make decisions based on actual runtime values. The author has observed that, when a MOP is available, uses of the more powerful and dynamic features of the MOP are relatively rare, that is, most individual methods do not use advanced features of the MOP. Also, for any given application, use of the MOP will tend to be fairly constrained and predictable.

Read the paper · More papers on PaperTik