Your browser doesn't support the features required by impress.js, so you are presented with a simplified version of this presentation.
For the best experience please use the latest Chrome, Safari or Firefox browser.
Aspect-
Oriented
Programming
by examples
@AkimBoyko
A well-written program is a program where the cost of implementing a feature is constant throughout the program's lifetime
Itay Maman
Aspect: appearance, visible form, the action of looking at appearance to the eye or mind
Advice: an opinion or a suggestion about what somebody should do in a particular situation
Weaver: a person whose job is weaving cloth
Composition: the combining of distinct parts or elements to form a whole
Intercept: to stop, deflect, or interrupt the progress or intended course o
Scattering: the dispersal of a beam of particles or of radiation into a range of directions as a result of physical interactions; placed irregularly and far apart
Tangling: To mix together or intertwine in a confused mass
When to apply?
- Code Tangling
- Code Scattering
- Code Coupling
- Boilerplate code
Cross-Cutting concerns
- Logging and Monitoring
- Performance analysis
- Debugging and Tracing
- Undo Functionality
- Validation of inputs and outputs
- Morphing the behavior of existing objects
- Object Filters
- Security Implementation
- Managing transactions
AOP w/o AOP
Is it possible at all? Déjà vu
-
Proxy and Decorator
- nHiberante: Lazy Loading
- DI containers: Interceptors
-
ASP.NET MVC Action Filter
IAuthorizationFilter: OnAuthorization()
IActionFilter: OnActionExecuted(), OnActionExecuting()
IExceptionFilter: OnException()
- Code Contract
- Demo #1
Poor man's AOP
- Decorator: extend an instance without changing class
- Proxy: substitute initial instance
- Demo #2
- Single responsibility
- Open/closed
- Liskov substitution
Interface segregation
- Dependency inversion
- Don't Repeat Yourself
AOP components
- Component language
- Aspect language
- Aspect weaver
- Aspect life time
- Demo #3: Aspect, IL and weaving and Dynaminc Interceptor
- Describe the transformation.
- Apply the transformation to the business code.
- Because there are two phases we separate all the aspect code from the business code.
Get nice separation of concerns and principally nice business code.
Gael Fraiteur
AOP Examples
Demo #4
- Authorization/Authentication
- Parameters Validation
- Auditing/Affiliation
- Transaction handling
- Inject dependencies into aspect
- Architecture Validation
- Modify external libraries calls
Other examples
- Declarative threading
- Circuit breaker
- Deadlocks detection
- Error handling
- … and a lot more
Post-compile vs. Runtime
PostSharp vs. Castle Dynamic Proxy
- Run-time performance
- Interception
- Interface/virtual functions
- No need to recompile
- Post-compilation
- WCF services and WPF forms, no way to hide behind proxy
- Lack of information during compile-time
AOP and testing
- Testing of separate aspects in isolation
- Testing of aspect composition and configuration
- Post-compilation: Need to manually create classes to apply aspects
AOP as anti-patter and alternatives
- Black magic or silver bullet? Neither!
- AOP vs. Dependency Injection
- AOP Weaver vs. Interfaces Decoration
- Aspects vs. Convension over Configuration
- B/L in AOP
- CI server integration
Resources