SlideShare una empresa de Scribd logo
1 de 22
AOP with PostSharp NCSoft China PD Dept. training  - Session 4 -- Lance Zhang http://blodfox777.cnblogs.com I am not an AOP expert.
Topics What is AOP Existing AOP Frameworks in .NET Introduce PostSharp  How does PostSharp work How to use PostSharp Q & A
Suppose We have a System… It Grows… Code Smells similar… Now We've Got A Problem(Ctrl + C/V)… So We Concerns…
Application Concerns Functional Requirements Line-of-business. Non-Functional Concerns Logging Caching Transaction Security Validation Persistence …
Enter the Aspect. What is AOP?
Aspects - Reduce noise in source Move plumbing out of source, but keep behaviour the same AOP … doesn’t solve any new problems. is just too complex. adoption is all or nothing. Promotes sloppy design. Aspects … obscure program flow. can’t be unit tested. Debugging with Aspects is hard.
Aspects Lingo Advice The duplicated plumbing code we are removing Typically under 30 lines of code Behaviour that is injected at a join point Join points Places within the code where the Aspect is inserted Examples Entry/Exit of a method or property Class’s Type Definition
Aspects Lingo Point cut Locates Join Points to apply advice Filter  driven– Automatic injection Find all Methods, of type Setter, in all classes where Namespace equals “Application.Entities” Attribute driven – Manual injection
Aspects Lingo Weaving Process of injecting functionality back into a component Can be performed by Text post processor – Magic comments can replaced by code Proxy container – Uses decorator pattern/hooks to allow code to be inserted Binary manipulation - Modifying assemblies - by replacing and injecting IL code
Existing AOP Frameworks in .NET AOP with Castle Windsor Dynamic Proxy Dynamic Proxy does the heavy-lifting of the IL generation for us Much easier for most requirements AOP with Spring.NET Can use something other than attributes such as XML configuration. Sorry, but actually I am unfamiliar with them…
Enter the PostSharp What is PostSharp? ,[object Object]
PostSharp is an Aspect-Oriented Framework,[object Object]
Easy to use  - like normal Attribute 
Intercept any method  - not only Virtual
More Join points  - on: field access, exception
More controllability  - break, change param or return
More transparent- no need “new proxy()”
Multicasting Custom Attributes- filter
Code quality after injection
Complexity of Debug ,[object Object],[object Object],[object Object]
Assembly Before/After Injection  Before Injection ,[object Object],[object Object]
When Can PostSharp Insert Code?  PostSharp.Laos.OnMethodBoundaryAspect OnEntry OnExit OnSuccess OnException PostSharp.Laos.OnMethodInvocationAspect OnInvocation PostSharp.Laos.OnExceptionAspect OnException PostSharp.Laos.OnFieldAccessAspect OnGetValue OnSetValue

Más contenido relacionado

La actualidad más candente

Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineGil Fink
 
Productivity and scalability with Play and Scala
Productivity and scalability with Play and ScalaProductivity and scalability with Play and Scala
Productivity and scalability with Play and ScalaChristophe Marchal
 
Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Mindfire Solutions
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Bertrand Delacretaz
 
Solving cross cutting concerns in PHP - PHPSerbia-2017
Solving cross cutting concerns in PHP - PHPSerbia-2017Solving cross cutting concerns in PHP - PHPSerbia-2017
Solving cross cutting concerns in PHP - PHPSerbia-2017Alexander Lisachenko
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure TestingRanjib Dey
 
Mock cli with Python unittest
Mock cli with Python unittestMock cli with Python unittest
Mock cli with Python unittestSong Jin
 
Code quality
Code qualityCode quality
Code quality44ue
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016Joe Ferguson
 
Introducing Ghost Inspector
Introducing Ghost InspectorIntroducing Ghost Inspector
Introducing Ghost InspectorNeil Mansilla
 
Automation testing API in Java
Automation testing API in JavaAutomation testing API in Java
Automation testing API in JavaWix.com
 
Testing with laravel
Testing with laravelTesting with laravel
Testing with laravelDerek Binkley
 

La actualidad más candente (20)

AOP on Android
AOP on AndroidAOP on Android
AOP on Android
 
Quick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmineQuick tour to front end unit testing using jasmine
Quick tour to front end unit testing using jasmine
 
Paper CS
Paper CSPaper CS
Paper CS
 
Productivity and scalability with Play and Scala
Productivity and scalability with Play and ScalaProductivity and scalability with Play and Scala
Productivity and scalability with Play and Scala
 
0 to Angular in 45 Mins
0 to Angular in 45 Mins0 to Angular in 45 Mins
0 to Angular in 45 Mins
 
Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1Asynchronous Programming in C# - Part 1
Asynchronous Programming in C# - Part 1
 
Tdd for php
Tdd for phpTdd for php
Tdd for php
 
Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?Karate, the black belt of HTTP API testing?
Karate, the black belt of HTTP API testing?
 
Solving cross cutting concerns in PHP - PHPSerbia-2017
Solving cross cutting concerns in PHP - PHPSerbia-2017Solving cross cutting concerns in PHP - PHPSerbia-2017
Solving cross cutting concerns in PHP - PHPSerbia-2017
 
Front-End UnitTesting
Front-End UnitTestingFront-End UnitTesting
Front-End UnitTesting
 
Wax on, wax off
Wax on, wax offWax on, wax off
Wax on, wax off
 
Karate DSL
Karate DSLKarate DSL
Karate DSL
 
Automated Infrastructure Testing
Automated Infrastructure TestingAutomated Infrastructure Testing
Automated Infrastructure Testing
 
Refactoring
RefactoringRefactoring
Refactoring
 
Mock cli with Python unittest
Mock cli with Python unittestMock cli with Python unittest
Mock cli with Python unittest
 
Code quality
Code qualityCode quality
Code quality
 
So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016So You Just Inherited a $Legacy Application… NomadPHP July 2016
So You Just Inherited a $Legacy Application… NomadPHP July 2016
 
Introducing Ghost Inspector
Introducing Ghost InspectorIntroducing Ghost Inspector
Introducing Ghost Inspector
 
Automation testing API in Java
Automation testing API in JavaAutomation testing API in Java
Automation testing API in Java
 
Testing with laravel
Testing with laravelTesting with laravel
Testing with laravel
 

Destacado

Performance Monitoring with AOP and Amazon CloudWatch
Performance Monitoring with AOP and Amazon CloudWatchPerformance Monitoring with AOP and Amazon CloudWatch
Performance Monitoring with AOP and Amazon CloudWatchYan Cui
 
Hoe iwt subsidie aanvragen
Hoe iwt subsidie aanvragenHoe iwt subsidie aanvragen
Hoe iwt subsidie aanvragenHans Haagdorens
 
Considering flipping
Considering flippingConsidering flipping
Considering flippingdsantur
 
Rangkuman penelitian ilmiah
Rangkuman penelitian ilmiahRangkuman penelitian ilmiah
Rangkuman penelitian ilmiahSigit Yunanto
 
How To Unfreeze iPod Nano or Touch
How To Unfreeze iPod Nano or TouchHow To Unfreeze iPod Nano or Touch
How To Unfreeze iPod Nano or Touchsurfingskimmer7
 
Financial Regulatory Reform: A New Foundation
Financial Regulatory Reform: A New FoundationFinancial Regulatory Reform: A New Foundation
Financial Regulatory Reform: A New FoundationColumbia
 
Bessels Architekten & Ingenieurs: Logistiek Industrie Kantoren
Bessels Architekten & Ingenieurs: Logistiek Industrie KantorenBessels Architekten & Ingenieurs: Logistiek Industrie Kantoren
Bessels Architekten & Ingenieurs: Logistiek Industrie KantorenFrederiek Muller
 
Par Stories 6
Par Stories 6Par Stories 6
Par Stories 6SDuhig
 
How To Add Social Networking Buttons To Your Outlook Email Signature
How To Add Social Networking Buttons To Your Outlook Email SignatureHow To Add Social Networking Buttons To Your Outlook Email Signature
How To Add Social Networking Buttons To Your Outlook Email SignatureAK Stout
 
Digital Portfolio
Digital PortfolioDigital Portfolio
Digital Portfoliotedollier
 
Using Video, High-Definition Photography, and 3-D Walkthroughs to Market Real...
Using Video, High-Definition Photography, and 3-D Walkthroughs to Market Real...Using Video, High-Definition Photography, and 3-D Walkthroughs to Market Real...
Using Video, High-Definition Photography, and 3-D Walkthroughs to Market Real...Tom Blefko
 
Participate in Sakai 3
Participate in Sakai 3Participate in Sakai 3
Participate in Sakai 3guest1411821
 
How to Successfully Negotiate with a Seller
How to Successfully Negotiate with a SellerHow to Successfully Negotiate with a Seller
How to Successfully Negotiate with a SellerTom Blefko
 
The Path to a Perfect Listing Presentation
The Path to a Perfect Listing PresentationThe Path to a Perfect Listing Presentation
The Path to a Perfect Listing PresentationTom Blefko
 
Res012913p
Res012913pRes012913p
Res012913pSDuhig
 

Destacado (20)

Performance Monitoring with AOP and Amazon CloudWatch
Performance Monitoring with AOP and Amazon CloudWatchPerformance Monitoring with AOP and Amazon CloudWatch
Performance Monitoring with AOP and Amazon CloudWatch
 
Avery
AveryAvery
Avery
 
Hoe iwt subsidie aanvragen
Hoe iwt subsidie aanvragenHoe iwt subsidie aanvragen
Hoe iwt subsidie aanvragen
 
Considering flipping
Considering flippingConsidering flipping
Considering flipping
 
B Avery
B AveryB Avery
B Avery
 
Rangkuman penelitian ilmiah
Rangkuman penelitian ilmiahRangkuman penelitian ilmiah
Rangkuman penelitian ilmiah
 
How To Unfreeze iPod Nano or Touch
How To Unfreeze iPod Nano or TouchHow To Unfreeze iPod Nano or Touch
How To Unfreeze iPod Nano or Touch
 
i-5 an alternate road to gittin' er done
i-5 an alternate road to gittin' er donei-5 an alternate road to gittin' er done
i-5 an alternate road to gittin' er done
 
IOAについて
IOAについてIOAについて
IOAについて
 
Financial Regulatory Reform: A New Foundation
Financial Regulatory Reform: A New FoundationFinancial Regulatory Reform: A New Foundation
Financial Regulatory Reform: A New Foundation
 
Bessels Architekten & Ingenieurs: Logistiek Industrie Kantoren
Bessels Architekten & Ingenieurs: Logistiek Industrie KantorenBessels Architekten & Ingenieurs: Logistiek Industrie Kantoren
Bessels Architekten & Ingenieurs: Logistiek Industrie Kantoren
 
Par Stories 6
Par Stories 6Par Stories 6
Par Stories 6
 
How To Add Social Networking Buttons To Your Outlook Email Signature
How To Add Social Networking Buttons To Your Outlook Email SignatureHow To Add Social Networking Buttons To Your Outlook Email Signature
How To Add Social Networking Buttons To Your Outlook Email Signature
 
Siguiendo el modelo
Siguiendo el modeloSiguiendo el modelo
Siguiendo el modelo
 
Digital Portfolio
Digital PortfolioDigital Portfolio
Digital Portfolio
 
Using Video, High-Definition Photography, and 3-D Walkthroughs to Market Real...
Using Video, High-Definition Photography, and 3-D Walkthroughs to Market Real...Using Video, High-Definition Photography, and 3-D Walkthroughs to Market Real...
Using Video, High-Definition Photography, and 3-D Walkthroughs to Market Real...
 
Participate in Sakai 3
Participate in Sakai 3Participate in Sakai 3
Participate in Sakai 3
 
How to Successfully Negotiate with a Seller
How to Successfully Negotiate with a SellerHow to Successfully Negotiate with a Seller
How to Successfully Negotiate with a Seller
 
The Path to a Perfect Listing Presentation
The Path to a Perfect Listing PresentationThe Path to a Perfect Listing Presentation
The Path to a Perfect Listing Presentation
 
Res012913p
Res012913pRes012913p
Res012913p
 

Similar a Aop With Post Sharp

Aspect oriented programming in .Net
Aspect oriented programming in .NetAspect oriented programming in .Net
Aspect oriented programming in .NetPaul Fryer
 
Using Apache Camel as AKKA
Using Apache Camel as AKKAUsing Apache Camel as AKKA
Using Apache Camel as AKKAJohan Edstrom
 
Aspect oriented programming
Aspect oriented programmingAspect oriented programming
Aspect oriented programmingRobert MacLean
 
Spring.Net, Feb 2008, PostSharp: A Technical Introduction
Spring.Net, Feb 2008, PostSharp:  A Technical IntroductionSpring.Net, Feb 2008, PostSharp:  A Technical Introduction
Spring.Net, Feb 2008, PostSharp: A Technical Introductiongfraiteur
 
Aspect-Oriented Programming and Depedency Injection
Aspect-Oriented Programming and Depedency InjectionAspect-Oriented Programming and Depedency Injection
Aspect-Oriented Programming and Depedency InjectionRobert Lemke
 
Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)Yan Cui
 
AWS Lambda from the trenches
AWS Lambda from the trenchesAWS Lambda from the trenches
AWS Lambda from the trenchesYan Cui
 
Jstorm introduction-0.9.6
Jstorm introduction-0.9.6Jstorm introduction-0.9.6
Jstorm introduction-0.9.6longda feng
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipseanshunjain
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleArnaud LEMAIRE
 
Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)Yan Cui
 
Fuzzing Linux Kernel
Fuzzing Linux KernelFuzzing Linux Kernel
Fuzzing Linux KernelPiyush Mishra
 
Asynchronous Service Server
Asynchronous Service ServerAsynchronous Service Server
Asynchronous Service Serverguestbba9241
 
Aspect j introduction for non-programmers
Aspect j introduction for non-programmersAspect j introduction for non-programmers
Aspect j introduction for non-programmersTamas Rev
 
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)Yan Cui
 
Spring - Part 3 - AOP
Spring - Part 3 - AOPSpring - Part 3 - AOP
Spring - Part 3 - AOPHitesh-Java
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with PythonAbhay Bhargav
 
RxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programmingRxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programmingMaciej Kołek
 

Similar a Aop With Post Sharp (20)

Aspect oriented programming in .Net
Aspect oriented programming in .NetAspect oriented programming in .Net
Aspect oriented programming in .Net
 
Using Apache Camel as AKKA
Using Apache Camel as AKKAUsing Apache Camel as AKKA
Using Apache Camel as AKKA
 
Aspect oriented programming
Aspect oriented programmingAspect oriented programming
Aspect oriented programming
 
Spring.Net, Feb 2008, PostSharp: A Technical Introduction
Spring.Net, Feb 2008, PostSharp:  A Technical IntroductionSpring.Net, Feb 2008, PostSharp:  A Technical Introduction
Spring.Net, Feb 2008, PostSharp: A Technical Introduction
 
Aspect-Oriented Programming and Depedency Injection
Aspect-Oriented Programming and Depedency InjectionAspect-Oriented Programming and Depedency Injection
Aspect-Oriented Programming and Depedency Injection
 
Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)Serverless in production, an experience report (CoDe-Conf)
Serverless in production, an experience report (CoDe-Conf)
 
Spring AOP
Spring AOPSpring AOP
Spring AOP
 
AWS Lambda from the trenches
AWS Lambda from the trenchesAWS Lambda from the trenches
AWS Lambda from the trenches
 
WoMakersCode 2016 - Shit Happens
WoMakersCode 2016 -  Shit HappensWoMakersCode 2016 -  Shit Happens
WoMakersCode 2016 - Shit Happens
 
Jstorm introduction-0.9.6
Jstorm introduction-0.9.6Jstorm introduction-0.9.6
Jstorm introduction-0.9.6
 
Understanding Framework Architecture using Eclipse
Understanding Framework Architecture using EclipseUnderstanding Framework Architecture using Eclipse
Understanding Framework Architecture using Eclipse
 
DevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & AnsibleDevOps, A brief introduction to Vagrant & Ansible
DevOps, A brief introduction to Vagrant & Ansible
 
Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)Serverless in production, an experience report (LNUG)
Serverless in production, an experience report (LNUG)
 
Fuzzing Linux Kernel
Fuzzing Linux KernelFuzzing Linux Kernel
Fuzzing Linux Kernel
 
Asynchronous Service Server
Asynchronous Service ServerAsynchronous Service Server
Asynchronous Service Server
 
Aspect j introduction for non-programmers
Aspect j introduction for non-programmersAspect j introduction for non-programmers
Aspect j introduction for non-programmers
 
Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)Serverless in Production, an experience report (cloudXchange)
Serverless in Production, an experience report (cloudXchange)
 
Spring - Part 3 - AOP
Spring - Part 3 - AOPSpring - Part 3 - AOP
Spring - Part 3 - AOP
 
we45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Pythonwe45 DEFCON Workshop - Building AppSec Automation with Python
we45 DEFCON Workshop - Building AppSec Automation with Python
 
RxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programmingRxSwift for Beginners - how to avoid a headache of reactive programming
RxSwift for Beginners - how to avoid a headache of reactive programming
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 

Aop With Post Sharp

  • 1. AOP with PostSharp NCSoft China PD Dept. training - Session 4 -- Lance Zhang http://blodfox777.cnblogs.com I am not an AOP expert.
  • 2. Topics What is AOP Existing AOP Frameworks in .NET Introduce PostSharp  How does PostSharp work How to use PostSharp Q & A
  • 3. Suppose We have a System… It Grows… Code Smells similar… Now We've Got A Problem(Ctrl + C/V)… So We Concerns…
  • 4. Application Concerns Functional Requirements Line-of-business. Non-Functional Concerns Logging Caching Transaction Security Validation Persistence …
  • 5. Enter the Aspect. What is AOP?
  • 6. Aspects - Reduce noise in source Move plumbing out of source, but keep behaviour the same AOP … doesn’t solve any new problems. is just too complex. adoption is all or nothing. Promotes sloppy design. Aspects … obscure program flow. can’t be unit tested. Debugging with Aspects is hard.
  • 7. Aspects Lingo Advice The duplicated plumbing code we are removing Typically under 30 lines of code Behaviour that is injected at a join point Join points Places within the code where the Aspect is inserted Examples Entry/Exit of a method or property Class’s Type Definition
  • 8. Aspects Lingo Point cut Locates Join Points to apply advice Filter driven– Automatic injection Find all Methods, of type Setter, in all classes where Namespace equals “Application.Entities” Attribute driven – Manual injection
  • 9. Aspects Lingo Weaving Process of injecting functionality back into a component Can be performed by Text post processor – Magic comments can replaced by code Proxy container – Uses decorator pattern/hooks to allow code to be inserted Binary manipulation - Modifying assemblies - by replacing and injecting IL code
  • 10. Existing AOP Frameworks in .NET AOP with Castle Windsor Dynamic Proxy Dynamic Proxy does the heavy-lifting of the IL generation for us Much easier for most requirements AOP with Spring.NET Can use something other than attributes such as XML configuration. Sorry, but actually I am unfamiliar with them…
  • 11.
  • 12.
  • 13. Easy to use - like normal Attribute 
  • 14. Intercept any method - not only Virtual
  • 15. More Join points - on: field access, exception
  • 16. More controllability - break, change param or return
  • 17. More transparent- no need “new proxy()”
  • 19. Code quality after injection
  • 20.
  • 21.
  • 22. When Can PostSharp Insert Code?  PostSharp.Laos.OnMethodBoundaryAspect OnEntry OnExit OnSuccess OnException PostSharp.Laos.OnMethodInvocationAspect OnInvocation PostSharp.Laos.OnExceptionAspect OnException PostSharp.Laos.OnFieldAccessAspect OnGetValue OnSetValue
  • 23. Other Aspects PostSharp.Laos.ImplementMethodAspect  Replace a method’s content with the advice in the aspect Useful for modifying 3rd party components PostSharp.Laos.CompositionAspect Allows an interface/state to be injected into a component Used to simulate multiple inheritance Examples include Adding .NET Win Form data binding to a POCO Adding Entity Framework interfaces to a POCO
  • 24. References PostSharp - David Ross Introduction to AOP with PostSharp - Michael D. Hall What Is PostSharp? - http://www.postsharp.org Using AOP and PostSharp to Enhance Your Code: Part A - Doron's .NET Space PostSharp - Lightweight Aspect-Oriented System - http://www.rainsts.net/
  • 25. Learn more... http://www.postsharp.org/ http://davybrion.com/blog/category/postsharp/ http://www.codeplex.com/ValidationAspects http://www.eclipse.org/aspectj/doc/released/progguide/