SlideShare a Scribd company logo
Introduction 
to AOP
Programming paradigm 
which aims to increase modularity 
by allowing the separation of 
cross-cutting concerns 
en.wikipedia.org/wiki/aspect-oriented-programming
Programming Paradigm 
It is *NOT* 
- a programming language 
- solution to all your problems 
- a first class citizen in Java 
or .NET 
- a replacement for OOP 
It is 
- a programming pattern 
- a tool in your toolbox 
- an easily added language 
feature 
- complimentary to OOP
Modularity 
Aspects can… 
• Exist in isolated and encapsulated constructs 
• Be attached to almost any standard code construct 
• Be transported between projects
Cross-Cutting Concerns 
…aspects of a program that affect other concerns. 
These concerns often cannot be cleanly decomposed 
from the rest of the system in both the design and 
implementation, 
and can result in either scattering (code duplication), 
tangling (significant dependencies between systems), 
or both. 
http://en.wikipedia.org/wiki/Cross-cutting_concern
…more simply 
Any code functionality that repeats itself in a regular 
pattern across many unrelated tiers/layers within a 
codebase.
Introduction To AOP
Cross-Cutting Concerns 
View 
ViewModel 
Model 
Services 
Domain Model 
Repositories 
Logging 
Security 
Auditing 
Validation 
INotifyPropertyChanged 
Undo/Redo 
Thread Management 
Unit of Work Management 
Circuit Breaker
AOP Styles 
1. Interception 
Interjecting the execution of cross-cutting concerns at 
run time. 
Non-invasive approach to modifying the code execution 
path. 
2. IL Weaving 
Interjecting the planned execution of cross-cutting 
concerns during the compilation process. 
Invasive approach to modifying the code execution 
path.
Interception 
• Existing in IoC container implementations 
• Follows a very strict decorator pattern 
• Likely implemented using weak typing 
• Run-time operation 
• Can be applied en-masse 
• Easy to implement if you’re already using IoC
Decorator Pattern 
//new functionality before 
//the code that already exists 
//new functionality after 
//exception handling
Weak Typing
En-masse Attachment
IL Weaving 
• Post compilation process 
• Alters the assembly/executable at an IL level 
• Scary to people 
• Can be attached to almost every code construct 
• Very rare that it required changes to existing code 
• Run and compile time operations 
• Can be much easier to add to legacy code
The Process 
Write Code 
Compile 
Application exe/dll 
AOP post 
compiler/weaver 
Throw 
compile-time 
error 
Deploy exe/dll
Constructs 
• Methods (private/public/internal/etc) 
• Properties 
• Field level variables 
• Events 
• Event registration/de-registration 
• Code generation
Run Time vs Compile Time 
Run Time 
• All aspect code executes in application context 
Compile Time 
• Code can be designated to run during post-compilation 
• Compilation can fail for correct syntaxes but incorrect 
business logic
Tooling 
• Interception 
• Castle Winsdor 
• StructureMap 
• Ninject (with Ninject.Extensions) 
• AutoFac (with Autofac.Extras) 
• IL Weaving 
• PostSharp (current) 
• LinFu
The Traditional Arguments Against AOP 
• It is “magic” 
• We won’t be able to debug properly 
• How do we know where aspects will be executed? 
• It’s another thing we have to learn 
• Changing the aspect will break the entire application
“Its magic!” & “We can’t debug it!” 
• Both interception and IL weaving provide full line-by-line 
debugging 
• Attachment of aspects is explicit as you want it to be
“But which aspect(s) will run?” 
• This is a tooling/discoverability problem, not a problem with 
AOP itself 
• PostSharp has very good VS integration showing what aspects 
are attached to a piece of code 
• Interceptor discoverability is a bigger problem
“Its another thing we have to learn” 
Is it worse if we train them and 
they leave or if we don’t train 
them and they stay?
“Changing the aspect can break the 
entire application!” 
• You can probably do that in an number of different ways with 
any codebase that doesn’t use AOP 
• This is a problem caused by tight coupling and poor separation 
of concerns
Your Project is Already Established… 
You use IoC 
• For logging, caching and possibly transaction management use 
interception 
• If the cross cutting concerns are more complex (Undo/Redo, 
thread management) use IL Weaving 
You don’t use IoC 
• The only real option is to use IL Weaving
You’re Starting a New Project… 
You have AOP buy-in from senior developers 
• Start with IL Weaving, but start with simple, pre-built aspects 
• Write custom aspects as experience and need grows 
AOP is still unknown to the senior people on the team 
• Start with IL Weaving, but start in a very isolated manner 
• Use this as a proof of concept until you have senior level buy-in
gracias 
Donald Belcham 
@dbelcham 
donald.belcham@igloocoder.com

More Related Content

What's hot (19)

PPTX
Key considerations for multithreaded architectures in LabVIEW
Piotr Demski
 
PPTX
PHP Frameworks, or how I learnt to stop worrying and love the code
Michal Juhas
 
PPTX
Power-Up Your Test Suite with OLE Automation by Joshua Russell
QA or the Highway
 
PDF
Behaviour testing for single-page applications and API’s
Andrew Kirkpatrick
 
PDF
Ten Advices for Architects
Eberhard Wolff
 
PPTX
Accelerating time to delivery modern tools for cobol development
Micro Focus
 
PDF
Containerizing legacy applications
Andrew Kirkpatrick
 
PDF
Robot Framework with actual robot
Eficode
 
PPTX
Entity Framework: To the Unit of Work Design Pattern and Beyond
Steve Westgarth
 
PPTX
QAorHighway2016
Bhupesh Dahal
 
PPTX
Next Level Unit Testing - Javacro 2019 - Dominik Poljak
Dominik Poljak
 
PDF
Belfast Selenium Meetup
Justin Ison
 
PPTX
Helpful Automation Techniques - Selenium Camp 2014
Justin Ison
 
PPTX
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
PDF
DCAST Meetup - Washington, DC Feb 2016
Justin Ison
 
PDF
Test-driven development with Node.js
Mirko Kiefer
 
PPTX
Benefits from AATs
Wyn B. Van Devanter
 
PPTX
Improving the Quality of Existing Software
Steven Smith
 
PPT
Zero redeployment with JRebel
Minh Hoang
 
Key considerations for multithreaded architectures in LabVIEW
Piotr Demski
 
PHP Frameworks, or how I learnt to stop worrying and love the code
Michal Juhas
 
Power-Up Your Test Suite with OLE Automation by Joshua Russell
QA or the Highway
 
Behaviour testing for single-page applications and API’s
Andrew Kirkpatrick
 
Ten Advices for Architects
Eberhard Wolff
 
Accelerating time to delivery modern tools for cobol development
Micro Focus
 
Containerizing legacy applications
Andrew Kirkpatrick
 
Robot Framework with actual robot
Eficode
 
Entity Framework: To the Unit of Work Design Pattern and Beyond
Steve Westgarth
 
QAorHighway2016
Bhupesh Dahal
 
Next Level Unit Testing - Javacro 2019 - Dominik Poljak
Dominik Poljak
 
Belfast Selenium Meetup
Justin Ison
 
Helpful Automation Techniques - Selenium Camp 2014
Justin Ison
 
Testing Rapidly Changing Applications With Self-Testing Object-Oriented Selen...
seleniumconf
 
DCAST Meetup - Washington, DC Feb 2016
Justin Ison
 
Test-driven development with Node.js
Mirko Kiefer
 
Benefits from AATs
Wyn B. Van Devanter
 
Improving the Quality of Existing Software
Steven Smith
 
Zero redeployment with JRebel
Minh Hoang
 

Viewers also liked (7)

PPT
45 aop-programming
daotuan85
 
PPT
ASPECT ORIENTED PROGRAMING(aop)
kvsrteja
 
PPTX
Introduction to aop
Dror Helper
 
PDF
AOP - Ideology, Mainstream, and Practice
ademelt
 
PDF
How to build an AOP framework in ActionScript
Christophe Herreman
 
PPTX
Produce Cleaner Code with Aspect-Oriented Programming
PostSharp Technologies
 
PDF
How To Choose a Ceiling Fan
Del Mar Fans & Lighting
 
45 aop-programming
daotuan85
 
ASPECT ORIENTED PROGRAMING(aop)
kvsrteja
 
Introduction to aop
Dror Helper
 
AOP - Ideology, Mainstream, and Practice
ademelt
 
How to build an AOP framework in ActionScript
Christophe Herreman
 
Produce Cleaner Code with Aspect-Oriented Programming
PostSharp Technologies
 
How To Choose a Ceiling Fan
Del Mar Fans & Lighting
 
Ad

Similar to Introduction To AOP (20)

PDF
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
mfrancis
 
PPTX
Introduction to Aspect Oriented Programming (DDD South West 4.0)
Yan Cui
 
KEY
The Architect Way
Jan Jongboom
 
PDF
Orthogonality: A Strategy for Reusable Code
rsebbe
 
PDF
NetWork - 15.10.2011 - Applied code generation in .NET
Dmytro Mindra
 
PPTX
MWLUG 2015 - An Introduction to MVC
Ulrich Krause
 
PPT
JAVA object oriented programming (oop).ppt
AliyaJav
 
PPTX
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
PDF
Stackato v6
Jonas Brømsø
 
PPT
Developing modular Java applications
Julien Dubois
 
PPTX
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
PDF
Stackato
Jonas Brømsø
 
PPT
Succeding with the Apache SOA stack
Johan Edstrom
 
PPTX
Features of Java.pptx
Peter Jose
 
PDF
Starting from scratch in 2017
Stefano Bonetta
 
PPTX
.net Based Component Technologies
prakashk453625
 
PPTX
Java training in bangalore
zasi besant
 
PPTX
Survive the Chaos - S4H151 - SAP TechED Barcelona 2017 - Lecture
Rainer Winkler
 
PPT
SWE6653_Implementing Software Architecture.ppt
huynhhviet
 
PPTX
Javascript best practices
Jayanga V. Liyanage
 
10 clues showing that you are doing OSGi in the wrong manner - Jerome Moliere
mfrancis
 
Introduction to Aspect Oriented Programming (DDD South West 4.0)
Yan Cui
 
The Architect Way
Jan Jongboom
 
Orthogonality: A Strategy for Reusable Code
rsebbe
 
NetWork - 15.10.2011 - Applied code generation in .NET
Dmytro Mindra
 
MWLUG 2015 - An Introduction to MVC
Ulrich Krause
 
JAVA object oriented programming (oop).ppt
AliyaJav
 
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
Stackato v6
Jonas Brømsø
 
Developing modular Java applications
Julien Dubois
 
Introduction to Spring & Spring BootFramework
Kongu Engineering College, Perundurai, Erode
 
Stackato
Jonas Brømsø
 
Succeding with the Apache SOA stack
Johan Edstrom
 
Features of Java.pptx
Peter Jose
 
Starting from scratch in 2017
Stefano Bonetta
 
.net Based Component Technologies
prakashk453625
 
Java training in bangalore
zasi besant
 
Survive the Chaos - S4H151 - SAP TechED Barcelona 2017 - Lecture
Rainer Winkler
 
SWE6653_Implementing Software Architecture.ppt
huynhhviet
 
Javascript best practices
Jayanga V. Liyanage
 
Ad

More from Donald Belcham (19)

PPTX
Introduction to Messaging
Donald Belcham
 
PDF
Advanced messaging patterns
Donald Belcham
 
PPTX
Microservices: The Nitty Gritty
Donald Belcham
 
PPTX
Microservices: A Gentle Introduction
Donald Belcham
 
PPTX
AOP & Patterns
Donald Belcham
 
PPTX
Source Control Abominations
Donald Belcham
 
PPTX
Is There Room for Craftsmanship in Software Development
Donald Belcham
 
PPTX
Reducing External Risk
Donald Belcham
 
PPTX
Performance Tuning in the Trenches
Donald Belcham
 
PPTX
Reliability and Resilience
Donald Belcham
 
PPTX
Reliability and Reslience
Donald Belcham
 
PPTX
Design patterns you didn't know about
Donald Belcham
 
PPTX
Programming Closer to the Iron
Donald Belcham
 
PPTX
Taming Brownfield Codebases with AOP
Donald Belcham
 
PPTX
Domain Driven Design Primer
Donald Belcham
 
PPTX
Hacking Hardware
Donald Belcham
 
PPTX
Advanced AOP
Donald Belcham
 
PPTX
The Dark Side of Code Metrics
Donald Belcham
 
PPTX
Continuous Deployment
Donald Belcham
 
Introduction to Messaging
Donald Belcham
 
Advanced messaging patterns
Donald Belcham
 
Microservices: The Nitty Gritty
Donald Belcham
 
Microservices: A Gentle Introduction
Donald Belcham
 
AOP & Patterns
Donald Belcham
 
Source Control Abominations
Donald Belcham
 
Is There Room for Craftsmanship in Software Development
Donald Belcham
 
Reducing External Risk
Donald Belcham
 
Performance Tuning in the Trenches
Donald Belcham
 
Reliability and Resilience
Donald Belcham
 
Reliability and Reslience
Donald Belcham
 
Design patterns you didn't know about
Donald Belcham
 
Programming Closer to the Iron
Donald Belcham
 
Taming Brownfield Codebases with AOP
Donald Belcham
 
Domain Driven Design Primer
Donald Belcham
 
Hacking Hardware
Donald Belcham
 
Advanced AOP
Donald Belcham
 
The Dark Side of Code Metrics
Donald Belcham
 
Continuous Deployment
Donald Belcham
 

Recently uploaded (20)

PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
PDF
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PDF
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
PPTX
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
PPTX
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
PDF
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
 
PDF
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
PPT
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
PDF
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PPTX
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
PDF
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
PPTX
Role Of Python In Programing Language.pptx
jaykoshti048
 
PDF
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
PDF
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
PDF
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
PDF
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
AI Image Enhancer: Revolutionizing Visual Quality”
docmasoom
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Download iTop VPN Free 6.1.0.5882 Crack Full Activated Pre Latest 2025
imang66g
 
GALILEO CRS SYSTEM | GALILEO TRAVEL SOFTWARE
philipnathen82
 
classification of computer and basic part of digital computer
ravisinghrajpurohit3
 
Applitools Platform Pulse: What's New and What's Coming - July 2025
Applitools
 
Brief History of Python by Learning Python in three hours
adanechb21
 
10 posting ideas for community engagement with AI prompts
Pankaj Taneja
 
Why Reliable Server Maintenance Service in New York is Crucial for Your Business
Sam Vohra
 
WatchTraderHub - Watch Dealer software with inventory management and multi-ch...
WatchDealer Pavel
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
ASSIGNMENT_1[1][1][1][1][1] (1) variables.pptx
kr2589474
 
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
Role Of Python In Programing Language.pptx
jaykoshti048
 
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
New Download MiniTool Partition Wizard Crack Latest Version 2025
imang66g
 
New Download FL Studio Crack Full Version [Latest 2025]
imang66g
 
How to Download and Install ADT (ABAP Development Tools) for Eclipse IDE | SA...
SAP Vista, an A L T Z E N Company
 

Introduction To AOP

  • 2. Programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns en.wikipedia.org/wiki/aspect-oriented-programming
  • 3. Programming Paradigm It is *NOT* - a programming language - solution to all your problems - a first class citizen in Java or .NET - a replacement for OOP It is - a programming pattern - a tool in your toolbox - an easily added language feature - complimentary to OOP
  • 4. Modularity Aspects can… • Exist in isolated and encapsulated constructs • Be attached to almost any standard code construct • Be transported between projects
  • 5. Cross-Cutting Concerns …aspects of a program that affect other concerns. These concerns often cannot be cleanly decomposed from the rest of the system in both the design and implementation, and can result in either scattering (code duplication), tangling (significant dependencies between systems), or both. http://en.wikipedia.org/wiki/Cross-cutting_concern
  • 6. …more simply Any code functionality that repeats itself in a regular pattern across many unrelated tiers/layers within a codebase.
  • 8. Cross-Cutting Concerns View ViewModel Model Services Domain Model Repositories Logging Security Auditing Validation INotifyPropertyChanged Undo/Redo Thread Management Unit of Work Management Circuit Breaker
  • 9. AOP Styles 1. Interception Interjecting the execution of cross-cutting concerns at run time. Non-invasive approach to modifying the code execution path. 2. IL Weaving Interjecting the planned execution of cross-cutting concerns during the compilation process. Invasive approach to modifying the code execution path.
  • 10. Interception • Existing in IoC container implementations • Follows a very strict decorator pattern • Likely implemented using weak typing • Run-time operation • Can be applied en-masse • Easy to implement if you’re already using IoC
  • 11. Decorator Pattern //new functionality before //the code that already exists //new functionality after //exception handling
  • 14. IL Weaving • Post compilation process • Alters the assembly/executable at an IL level • Scary to people • Can be attached to almost every code construct • Very rare that it required changes to existing code • Run and compile time operations • Can be much easier to add to legacy code
  • 15. The Process Write Code Compile Application exe/dll AOP post compiler/weaver Throw compile-time error Deploy exe/dll
  • 16. Constructs • Methods (private/public/internal/etc) • Properties • Field level variables • Events • Event registration/de-registration • Code generation
  • 17. Run Time vs Compile Time Run Time • All aspect code executes in application context Compile Time • Code can be designated to run during post-compilation • Compilation can fail for correct syntaxes but incorrect business logic
  • 18. Tooling • Interception • Castle Winsdor • StructureMap • Ninject (with Ninject.Extensions) • AutoFac (with Autofac.Extras) • IL Weaving • PostSharp (current) • LinFu
  • 19. The Traditional Arguments Against AOP • It is “magic” • We won’t be able to debug properly • How do we know where aspects will be executed? • It’s another thing we have to learn • Changing the aspect will break the entire application
  • 20. “Its magic!” & “We can’t debug it!” • Both interception and IL weaving provide full line-by-line debugging • Attachment of aspects is explicit as you want it to be
  • 21. “But which aspect(s) will run?” • This is a tooling/discoverability problem, not a problem with AOP itself • PostSharp has very good VS integration showing what aspects are attached to a piece of code • Interceptor discoverability is a bigger problem
  • 22. “Its another thing we have to learn” Is it worse if we train them and they leave or if we don’t train them and they stay?
  • 23. “Changing the aspect can break the entire application!” • You can probably do that in an number of different ways with any codebase that doesn’t use AOP • This is a problem caused by tight coupling and poor separation of concerns
  • 24. Your Project is Already Established… You use IoC • For logging, caching and possibly transaction management use interception • If the cross cutting concerns are more complex (Undo/Redo, thread management) use IL Weaving You don’t use IoC • The only real option is to use IL Weaving
  • 25. You’re Starting a New Project… You have AOP buy-in from senior developers • Start with IL Weaving, but start with simple, pre-built aspects • Write custom aspects as experience and need grows AOP is still unknown to the senior people on the team • Start with IL Weaving, but start in a very isolated manner • Use this as a proof of concept until you have senior level buy-in