Applying the Decorator Pattern for Profiling Object-Oriented Software
(Citations: 3)
A profiler can provide valuable information to a developer to facilitate program optimization, debug- ging or testing. In this paper, we describe the use of the Decorator pattern for non-intrusive profiling of object-oriented applications. We provide a for- mal specification of the Decorator pattern, and show that the pattern can be used as a program transfor- mation without altering the external, observable be- havior of the system. We refer to such a transfor- mation as a correctness preserving transformation, or CPT. As a CPT, the Decorator pattern can be used to non-intrusivelyprofile object-oriented appli- cations and we illustrate this application with an in- variant validator for enforcement of Design byCon- tract, and for profiling memory. We provide a case studyto compare the cost trade-offs of validating in- variants at different points in a program.