Aspects in Web Application Architectures


Published on

AOP is a way to deal with cross-cutting concerns in an application. Complex Web applications are a domain in which we find many cross-cutting concerns, spanning from presentation to content, from business logic to user agent and many more.
Being able to isolate all the different concerns in separate units of code and then being able to waeve them together in an aspect-oriented fashion would greatly simplify the application's architecture and improve its flexibility.

However, it's not always possible to use an AOP framework for the development of your Web application.

In this presentation we'll see how keeping a few AOP concepts in mind can lead to a better design. We'll also explore a few patterns that may help you to implement an aspect-oriented architecture even if you don't use an AOP framework.

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Aspects in Web Application Architectures

  1. 1. ASPECTS IN WEB APPLICATION ARCHITECTURES Andrea Provaglio Twitter: @andreaprovaglio Copyright © Andrea Provaglio - All Rights Reserved
  2. 2. What I Do After 20 years in IT, with clients in three continents and a U.S. visa for “extraordinary abilities in Sciences”, I now help IT organizations to explore new ways to develop better software. I also support teams and individuals who want to improve technically and relationally. Full bio at: http://
  3. 3. What We’ll Be Talking About • Aspects in a Nutshell • Complexities in Web Applications • Aspect-oriented Web Architectures
  4. 4. Aspects in a Nutshell Primary separation Cross-cutting (orthogonal) concerns of concerns (business logic) Security Transactions Auditing Add Item Remove Item Buy Join Point (pointcut)
  5. 5. Classic AspectJ Example aspect Logger { pointcut log(): call(public * BizObj.*(..)); before(): log() { System.out.println("before method call"); } after(): log() { System.out.println("after method call"); } } Note the se paration of oss-cutting concerns Advices cr
  6. 6. More About the Example • Uses a declarative language, which is better suited for describing facts rather than processes • Isolates common code, following the DRY principle • Easily configurable for added flexibility Think of Aspec ts as a way to formalize “WHENEVER”
  7. 7. Content vs. Presentation Separatin g Conten from Pre t sentation the basic is s, but o not enou ften gh.
  8. 8. (Semantic Content) ⊥ (Language)
  9. 9. (Content) ⊥ (Layout)
  10. 10. (Presentation) ⊥ (Accessibility 1)
  11. 11. (Presentation) ⊥ (Accessibility 2)
  12. 12. (Structural Content) ⊥ (Context)
  13. 13. (Generated Output) ⊥ (Client Agent)
  14. 14. When Aspects Fit In • Lots of “Whenever” in Web applications, but you can rarely use an AOP language for your Web development • So we need to start thinking in Aspects and find ways to achieve the benefits of Aspects without an AOP language
  15. 15. An Architectural Approach to Aspects • Domain-Specific Languages (well, almost) • Interception (Proxy, Chain of Responsibility, Template Method) • Event Handling (Observer)
  16. 16. A Common DSL: CSS #context-menu-container * ul { padding: 0; margin: 0 12px 0 0; white-space: normal; } hink about it.. . Isn’t this T almos t an Aspect?
  17. 17. Interception by Proxy • Proxy •“Provide a surrogate or placeholder for another object to control access to it.” [GoF]
  18. 18. Interception by C.o.R • Chain of Responsibility • “Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. [...]” [GoF]
  19. 19. Interception by Template Method • Template Method •“Define the skeleton of an algorithm in an operation, deferring some steps to subclasses. [...]” [GoF]
  20. 20. Front Controller and Filters • Front Controller • Use a contro%er as the initial point of contact for handling a request. • Filters • Create plu&able filters to process common services in a standard manner without requiring changes to core request processing code
  21. 21. Event Handling • Your application server of choice is likely to provide an application event facility (based on Observer) • Each event becomes a potential injection point for advices
  22. 22. Glue It All with Dependency Injection • An OOP technique for supplying an external dependency to a software component, indicating to a part of a program which other parts it can use • Using dependency injection, the life-cycle of a service is handled by a dependency provider (typically a container) rather than the consumer • Such a pattern involves at least three elements: a dependent, its dependencies and an injector (sometimes referred to as a provider or container) [excerpts from Wikipedia]
  23. 23. Wrap-up WHENEVER
  24. 24. Andrea Provaglio http: // me! act ont ?C info ore .: M P.S