The object-oriented approach has fundamentally changed the way we look at software, and has had an enormous influence on the software engineering discipline. Through the use of powerful tools such as inheritance and polymorphism, developers can specialize and enhance software systems while reusing large portions of already existing code. However, the use of these features can result in complex interactions and dependencies among parts of the code, which may make it difficult when trying to understand and reason about the system's behavior. We show how such difficulties can be addressed by the use of specifications which allow us to reason modularly about software systems. We also present a tool which allows for runtime monitoring of systems to identify any violations of these specifications. The tool exploits the same mechanisms of inheritance and polymorphism, and does not require the availability of system source code. We also look at how a similar approach can be applied to track the execution flow through OO class hierarchies.
Design patterns, a progression from class-level to design-level OO reuse, have also had a large impact on the way we think about and design large software systems. Patterns allow for the reuse of time-tested solutions, and enable others studying the system in question to get a deeper understanding of how the system is built and why it behaves in particular ways. Design patterns have traditionally been presented in an informal manner, however, and such descriptions often contain ambiguities that can lead to different interpretations and assumptions made about specific parts of the system. This can result in misunderstandings among developers working on the same project, and can eventually manifest themselves as incompatibilities among different parts of the system. Again, we need ways to precisely specify behaviors of patterns and systems built using them, as well as software tools to monitor the systems to identify any violations of the specifications. We present a pattern contract language that addresses the specificity of individual applications, while maintaining the flexibility inherent in the design patterns. We then present a tool which generates aspect-oriented monitors for checking pattern contract violations during runtime.