code prole

Icon

coding for the proletariat since 1977

AOP

I’ve been aware of Aspect Oriented Programming (AOP) for some time now, but I haven’t ever really looked into it. My current project team is angling for an architectural decision that would allow us to use the Spring framework for transaction management. In reading about Spring and experimenting with some sample code I’ve discovered that it is really an implementation of AOP.

Simply put, AOP seeks to address common aspects of objects across the layers of your application. Object Oriented Programming (OOP) allows us to model our applications after real world objects, making them easier to design, develop, and implement. However, there are some aspects of the real world that apply to multiple objects. When translated into source code these aspects often end up repeated in multiple objects. And we all know what happens when you start repeating code.

Take logging for example. Any application that has a logging requirement is likely to have calls to a logging service scattered through out the various layers of the application and the numerous objects comprising that layer. Wouldn’t it be better if the objects just focused on the business task at hand, while the logging was handled in a separate framework? That’s what AOP is all about. Every object in the application that requires logging services shares an aspect: the need for logging. Using AOP techniques and tools allows the application objects to be tightly focused on the business requirements, while the cross-cutting aspects are addressed through AOP.

Advertisements

Filed under: Aspect Oriented Programming