introduction to aspect oriented programming
TRANSCRIPT
![Page 1: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/1.jpg)
Introduction To
Aspect Oriented
Programming
Present in Tabriz Software Open Talks
Saeed Shargi Ghazani
@saeed_shargi
![Page 2: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/2.jpg)
Problem
![Page 3: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/3.jpg)
DRY
![Page 4: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/4.jpg)
Solutions
Some techniques include :
TemplateMetaprogramming
MetaObjectProtocol
Decorators
TemplateMethodPattern
RPC tools
Many of the Creational Patterns
MultipleInheritance and MixIns
ContextObject or ExplicitManagementOfImplicitContext
![Page 5: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/5.jpg)
Solutions
Programming paradigm solution deal with this problem is :
Aspect Oriented Programming
![Page 6: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/6.jpg)
History
Gregor Kiczales and colleagues at Xerox PARC in 1997
In 2001, the AspectJ extensions brought AOP to Java
IBM research team in 2001 proposed Hyper/J
Microsoft Transaction Server by EJB
![Page 7: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/7.jpg)
Intro
Software development technique that :
Increase modularity
Managing cross cutting concerns
Infrastructure composition
![Page 8: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/8.jpg)
Features
Cross-Cutting Concerns
Pieces of functionality that are used across multiple parts of a system
Cross-Cutting concerns and nonfunctional requirements have a lot of overlap
Advice
Code that performs the cross-cutting concerns
“What” of AOP
Pointcut
Join Point : Defined between logical steps
“Where” of AOP
![Page 9: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/9.jpg)
Features
Tangling
When cross-cutting concern code mixed with core code
Scattering
when cross-cutting concern code used in multiple methods
Weaving
combination of core codes with aspects
![Page 10: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/10.jpg)
Features
![Page 11: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/11.jpg)
Features
![Page 12: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/12.jpg)
Benefits
Clean Code
Reduce Repetition
Encapsulation
![Page 13: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/13.jpg)
Aspects
Encapsulating
Wrapper
SRP
Decorator Pattern
OCP
![Page 14: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/14.jpg)
Aspects Lifetime
OnStart
OnSuccess
OnExit
OnError
![Page 15: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/15.jpg)
Types
Interceptors
IL Code Weaving
![Page 16: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/16.jpg)
Interceptors
Calls to class methods or properties
IoC Container
No post compilation
Dynamic Proxy
![Page 17: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/17.jpg)
Interceptors
Common use of IoC Conainer
Calling Code IoC Container
IMyInterface
MyClass :IMyInterface
![Page 18: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/18.jpg)
Interceptors
Use of IoC Conainer with Dynamic Proxy
Calling Code IoC Container
IMyInterface
MyC
lass
:IM
yIn
terf
ac
e
Dynamic Proxy
Pro
xyIn
terc
ep
tor:
IMyIn
terf
ac
e
ProxyInterceptor:IMyInterface
![Page 19: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/19.jpg)
IL Code Weaving
Run after compilation
Post process
![Page 20: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/20.jpg)
IL Code Weaving
Common Tool to use :
![Page 21: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/21.jpg)
Example
Simple example in C# with Autofac IoC Container code’s is here
SayHelloToAOP
![Page 22: Introduction To Aspect Oriented Programming](https://reader034.vdocuments.site/reader034/viewer/2022042602/55a5ede51a28ab0d6b8b46ec/html5/thumbnails/22.jpg)
Resources
AOP in .NET, Matthew D. Groves, Manning Publications Co, 2013
Aspect Oriented Programming in .NET, Donald Belcham, Plurarsight, 2011
http://c2.com/cgi/wiki?CrossCuttingConcern
http://en.wikipedia.org/wiki/Aspect-oriented_programming