advertisement
Login | Register   
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   TIP BANK
Browse DevX
Partners & Affiliates
advertisement
advertisement
advertisement
advertisement
 

Implement Logging as an Aspect Using Spring's AOP Framework

Aspect-oriented programming (AOP) enables you to write code for a crosscutting functionality and then apply it declaratively to existing code. Logging is a prime candidate for implementation as an aspect, and Spring offers the AOP framework to get it done. 


advertisement
bject-oriented programming (OOP) brought about the concept of encapsulation, inheritance, and polymorphism in order to create a hierarchy of objects that models a common set of behaviors. So, a particular set of objects is modeled to depict a particular pattern of behavior. But OOP does not explain how to handle a common behavior that extends across unrelated objects. Hence, the same set of code (i.e., redundant code) is scattered throughout the system.

Take the case of logging, for example. Logging code is scattered horizontally across multiple object hierarchies most of the time, and it has nothing to do with the functionalities the object hierarchies represent. In other words, OOP best depicts the top-down (vertical) object relationship but it falls short in handling left-to-right (horizontal) object relationship. Aspect-oriented programming (AOP) facilitates the latter by referring horizontal object relationships as crosscutting concerns and separating them from core functionalities.


It's quick, easy and you get access to all the articles on DevX.
This registration/login is to allow you to read articles on devx.com.
Already a member?



advertisement