SlideShare uma empresa Scribd logo
1 de 53
Yan Cui
Server-side Developer @
“Our mission is to build fun games and game apps that
people can play, anywhere, anytime.”
 Overview
 Cross-Cutting Concerns
 AOP
 What’s in it for you
 AOP
 Terminologies
 AOP and OOP
 Solutions
 Q&A
The PROBLEM…
Image by Mark RohdeImage by Mike Rohde
Cross-Cutting Concerns
Function
Requirements
Non-Functional
Requirements
Production
Code
=+
 Cuts across multiple abstractions
 Difficult to decompose
 High-coupling
 Boilerplate code
 Code tangling and scattering
 Poor traceability
 Lower productivity
 Less code reuse
 Harder refactoring
The SOLUTION…
“AOP is a programming paradigm which aims to
increase modularity by allowing the separation
of cross-cutting concerns”
- wikipedia
Coding is HARD
AOP makes
it EASY
Image by Mark Rohde
AOP
 Centralize concerns implementation
 Intercept method calls
 Inject new behaviour
 More reusable code
 Cleaner code
What’s in it for YOU?
 Write less code
 Read less code
 More concise and easy to understand
 More maintainable
 Fewer code =
 Less boilerplate code
 More interesting work
 Increased attention
 More PRODUCTIVITY!
FEWER DEFECTS!
Diving a little deeper…
 Join Point
 Place where behaviour can be added
 Advice
 Code that can be injected at join points
 Point cut
 Join points where advice should be applied
 Aspect
 Container holding point cuts and advice
 Weaving
 Combines advices with point cuts
 AOP is complementary to OOP
 AOP targets a specific problem
 Code modularization
 OOP – Real world objects
 AOP – Functionalities
 Help you S.O.L.I.Dify your code
 Single responsibility
 Open/close
 You can do AOP via:
 Dynamic Proxies
 Functional Programming
 Code Generation
 Dynamic Languages
 Static Weaving
AOP via...
 IoC framesworks (Castle, Spring.Net)
 Dynamic interceptors
Image by Mark Rohde
Dynamic Proxies
 Advantages
 Can use existing DI framework
 Some frameworks provides built-in aspects
 Aspects can be configured after build
 Disadvantages
 Significant change to base code required to adapt
 Limited AOP features
 Do not work on static, non-public methods
 Do not work on fields, properties, or events
 Higher run-time overhead
 No build-time verification
 Objects must be instantiated using the container
Class, is AOP the same as
Dependency Injection?
NOOOO Sir!!
AOP via...
Image by Mark Rohde
Functional
Programming
 Advantages
 No external dependencies
 Disadvantages
 Requires modification to every function
 No support for matching rules
 Manual aspect composition
AOP via…
 T4, CodeSmith Tools
 Advantages
 Easy to generate complex source code
 Disadvantages
 Input is usually XML
 Cannot inject new behaviour to existing code
AOP via…
Image by Mark Rohde
Dynamic Languages
 Advantages
 Meta-programming is easy
 Disadvantages
 Switching to a dynamic language can be scary
 No (limited) Visual Studio tooling
AOP via…
 PostSharp, AspectJ
 Uses low-level MSIL transformation
 Compile time
Aspect Decomposition
Aspects Core program
Aspect Recomposition
Requirements
Final System
 Aspectual Decomposition
 Identify primary and cross-cutting concerns
 Concern Implementation
 Implement concerns separately
 Primary concern as Core Component using OO
 Cross-cutting concerns as aspect
 Aspectual Recomposition
 Aspect weaver to weave the separately
implemented code into a final system
Image by Mark Rohde
PostSharp
 Advantages
 Most complete support of AOP features
 Aspect usage is verified at build time
 Better runtime performance
 Disadvantages
 Increased build time
 New to many developers
PostSharp Training
@ SkillsMatter, London
January 19-20, 2012
http://www.sharpcrafters.com/training
jobs@iwi.com
Thank You!
Yan Cui
@theburningmonk
Introduction to Aspect Oriented Programming

Mais conteúdo relacionado

Mais procurados

Cqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For DevelopersCqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For Developerswojtek_s
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit TestingSøren Lund
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016Søren Lund
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Søren Lund
 
Code Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysisCode Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysisMikalai Alimenkou
 
Client Side Unit Testing
Client Side Unit TestingClient Side Unit Testing
Client Side Unit Testingcloud chen
 
Integrating the compiler with unit testing
Integrating the compiler with unit testingIntegrating the compiler with unit testing
Integrating the compiler with unit testingSimon Belak
 
Code Review
Code ReviewCode Review
Code ReviewRavi Raj
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool EvaluationKate Semizhon
 
Software testing
Software testing Software testing
Software testing MadeEasyCTC
 
Scrum Events and Artifacts in Action
Scrum Events and Artifacts in ActionScrum Events and Artifacts in Action
Scrum Events and Artifacts in ActionLemi Orhan Ergin
 
How to Effectively Test Your Chatbot | Rasa Summit
How to Effectively Test Your Chatbot  | Rasa SummitHow to Effectively Test Your Chatbot  | Rasa Summit
How to Effectively Test Your Chatbot | Rasa SummitRasa Technologies
 
DevOps & Technical Agility: From Theory to Practice
DevOps & Technical Agility: From Theory to PracticeDevOps & Technical Agility: From Theory to Practice
DevOps & Technical Agility: From Theory to PracticeLemi Orhan Ergin
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelinesLalit Kale
 

Mais procurados (19)

Cqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For DevelopersCqrs and Event Sourcing Intro For Developers
Cqrs and Event Sourcing Intro For Developers
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 
Solid principles
Solid principlesSolid principles
Solid principles
 
Documenting code yapceu2016
Documenting code yapceu2016Documenting code yapceu2016
Documenting code yapceu2016
 
Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016Documenting Code - Patterns and Anti-patterns - NLPW 2016
Documenting Code - Patterns and Anti-patterns - NLPW 2016
 
Code Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysisCode Review tool for personal effectiveness and waste analysis
Code Review tool for personal effectiveness and waste analysis
 
Client Side Unit Testing
Client Side Unit TestingClient Side Unit Testing
Client Side Unit Testing
 
Integrating the compiler with unit testing
Integrating the compiler with unit testingIntegrating the compiler with unit testing
Integrating the compiler with unit testing
 
Unit tests benefits
Unit tests benefitsUnit tests benefits
Unit tests benefits
 
Code Review
Code ReviewCode Review
Code Review
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool Evaluation
 
Software testing
Software testing Software testing
Software testing
 
10 Benefits of Automated Testing
10 Benefits of Automated Testing10 Benefits of Automated Testing
10 Benefits of Automated Testing
 
Microservices
MicroservicesMicroservices
Microservices
 
Scrum Events and Artifacts in Action
Scrum Events and Artifacts in ActionScrum Events and Artifacts in Action
Scrum Events and Artifacts in Action
 
How to Effectively Test Your Chatbot | Rasa Summit
How to Effectively Test Your Chatbot  | Rasa SummitHow to Effectively Test Your Chatbot  | Rasa Summit
How to Effectively Test Your Chatbot | Rasa Summit
 
Code Review
Code ReviewCode Review
Code Review
 
DevOps & Technical Agility: From Theory to Practice
DevOps & Technical Agility: From Theory to PracticeDevOps & Technical Agility: From Theory to Practice
DevOps & Technical Agility: From Theory to Practice
 
Code review guidelines
Code review guidelinesCode review guidelines
Code review guidelines
 

Semelhante a Introduction to Aspect Oriented Programming

Aspect oriented programming
Aspect oriented programmingAspect oriented programming
Aspect oriented programmingRobert MacLean
 
Introduction to Aspect Oriented Programming by Donald Belcham
Introduction to Aspect Oriented Programming by Donald BelchamIntroduction to Aspect Oriented Programming by Donald Belcham
Introduction to Aspect Oriented Programming by Donald Belcham.NET Conf UY
 
仕様決定、部品化、ディレクションがなぜ重要か
仕様決定、部品化、ディレクションがなぜ重要か仕様決定、部品化、ディレクションがなぜ重要か
仕様決定、部品化、ディレクションがなぜ重要かKohei Otsuka
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?Kasra Khosravi
 
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
Lennart Regebro   What Zope Did Wrong (And What To Do Instead)Lennart Regebro   What Zope Did Wrong (And What To Do Instead)
Lennart Regebro What Zope Did Wrong (And What To Do Instead)Vincenzo Barone
 
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
Lennart Regebro   What Zope Did Wrong (And What To Do Instead)Lennart Regebro   What Zope Did Wrong (And What To Do Instead)
Lennart Regebro What Zope Did Wrong (And What To Do Instead)Vincenzo Barone
 
Beyond the Oracle Forms Horizon: from Forms to ADF in minutes
Beyond the Oracle Forms Horizon: from Forms to ADF in minutes  Beyond the Oracle Forms Horizon: from Forms to ADF in minutes
Beyond the Oracle Forms Horizon: from Forms to ADF in minutes infoqafe
 
Oracle Forms Conversion "An automated Approach"
Oracle Forms Conversion "An automated Approach"Oracle Forms Conversion "An automated Approach"
Oracle Forms Conversion "An automated Approach"Rokesh Jankie
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Theo Jungeblut
 
Javascript Framework Roundup FYB
Javascript Framework Roundup FYBJavascript Framework Roundup FYB
Javascript Framework Roundup FYBnukeevry1
 
TDD - Cultivating a Beginner's Mind
TDD -  Cultivating a Beginner's MindTDD -  Cultivating a Beginner's Mind
TDD - Cultivating a Beginner's MindShai Yallin
 
Aspect oriented programming in .Net
Aspect oriented programming in .NetAspect oriented programming in .Net
Aspect oriented programming in .NetPaul Fryer
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET Dmytro Mindra
 
Introduction to Java Part-2
Introduction to Java Part-2Introduction to Java Part-2
Introduction to Java Part-2RatnaJava
 
API Centric Development in PHP
API Centric Development in PHPAPI Centric Development in PHP
API Centric Development in PHPJoe Stagner
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming GoWeng Wei
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java Hitesh-Java
 

Semelhante a Introduction to Aspect Oriented Programming (20)

Aspect oriented programming
Aspect oriented programmingAspect oriented programming
Aspect oriented programming
 
Introduction to Aspect Oriented Programming by Donald Belcham
Introduction to Aspect Oriented Programming by Donald BelchamIntroduction to Aspect Oriented Programming by Donald Belcham
Introduction to Aspect Oriented Programming by Donald Belcham
 
仕様決定、部品化、ディレクションがなぜ重要か
仕様決定、部品化、ディレクションがなぜ重要か仕様決定、部品化、ディレクションがなぜ重要か
仕様決定、部品化、ディレクションがなぜ重要か
 
What Web Framework To Use?
What Web Framework To Use?What Web Framework To Use?
What Web Framework To Use?
 
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
Lennart Regebro   What Zope Did Wrong (And What To Do Instead)Lennart Regebro   What Zope Did Wrong (And What To Do Instead)
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
 
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
Lennart Regebro   What Zope Did Wrong (And What To Do Instead)Lennart Regebro   What Zope Did Wrong (And What To Do Instead)
Lennart Regebro What Zope Did Wrong (And What To Do Instead)
 
Flutter
FlutterFlutter
Flutter
 
Beyond the Oracle Forms Horizon: from Forms to ADF in minutes
Beyond the Oracle Forms Horizon: from Forms to ADF in minutes  Beyond the Oracle Forms Horizon: from Forms to ADF in minutes
Beyond the Oracle Forms Horizon: from Forms to ADF in minutes
 
Oracle Forms Conversion "An automated Approach"
Oracle Forms Conversion "An automated Approach"Oracle Forms Conversion "An automated Approach"
Oracle Forms Conversion "An automated Approach"
 
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
Debugging,Troubleshooting & Monitoring Distributed Web & Cloud Applications a...
 
Javascript Framework Roundup FYB
Javascript Framework Roundup FYBJavascript Framework Roundup FYB
Javascript Framework Roundup FYB
 
TDD - Cultivating a Beginner's Mind
TDD -  Cultivating a Beginner's MindTDD -  Cultivating a Beginner's Mind
TDD - Cultivating a Beginner's Mind
 
Aspect oriented programming in .Net
Aspect oriented programming in .NetAspect oriented programming in .Net
Aspect oriented programming in .Net
 
Apex triggers i
Apex triggers iApex triggers i
Apex triggers i
 
NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET NetWork - 15.10.2011 - Applied code generation in .NET
NetWork - 15.10.2011 - Applied code generation in .NET
 
Introduction to Java Part-2
Introduction to Java Part-2Introduction to Java Part-2
Introduction to Java Part-2
 
API Centric Development in PHP
API Centric Development in PHPAPI Centric Development in PHP
API Centric Development in PHP
 
Metaprogramming Go
Metaprogramming GoMetaprogramming Go
Metaprogramming Go
 
API Design Workflows
API Design WorkflowsAPI Design Workflows
API Design Workflows
 
Introduction to Java
Introduction to Java Introduction to Java
Introduction to Java
 

Mais de Yan Cui

How to win the game of trade-offs
How to win the game of trade-offsHow to win the game of trade-offs
How to win the game of trade-offsYan Cui
 
How to choose the right messaging service
How to choose the right messaging serviceHow to choose the right messaging service
How to choose the right messaging serviceYan Cui
 
How to choose the right messaging service for your workload
How to choose the right messaging service for your workloadHow to choose the right messaging service for your workload
How to choose the right messaging service for your workloadYan Cui
 
Patterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdfPatterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdfYan Cui
 
Lambda and DynamoDB best practices
Lambda and DynamoDB best practicesLambda and DynamoDB best practices
Lambda and DynamoDB best practicesYan Cui
 
Lessons from running AppSync in prod
Lessons from running AppSync in prodLessons from running AppSync in prod
Lessons from running AppSync in prodYan Cui
 
Serverless observability - a hero's perspective
Serverless observability - a hero's perspectiveServerless observability - a hero's perspective
Serverless observability - a hero's perspectiveYan Cui
 
How to ship customer value faster with step functions
How to ship customer value faster with step functionsHow to ship customer value faster with step functions
How to ship customer value faster with step functionsYan Cui
 
How serverless changes the cost paradigm
How serverless changes the cost paradigmHow serverless changes the cost paradigm
How serverless changes the cost paradigmYan Cui
 
Why your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncWhy your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncYan Cui
 
Build social network in 4 weeks
Build social network in 4 weeksBuild social network in 4 weeks
Build social network in 4 weeksYan Cui
 
Patterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applicationsPatterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applicationsYan Cui
 
How to bring chaos engineering to serverless
How to bring chaos engineering to serverlessHow to bring chaos engineering to serverless
How to bring chaos engineering to serverlessYan Cui
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsYan Cui
 
Building a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQLBuilding a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQLYan Cui
 
FinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economyFinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economyYan Cui
 
How to improve lambda cold starts
How to improve lambda cold startsHow to improve lambda cold starts
How to improve lambda cold startsYan Cui
 
What can you do with lambda in 2020
What can you do with lambda in 2020What can you do with lambda in 2020
What can you do with lambda in 2020Yan Cui
 
A chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage awayA chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage awayYan Cui
 
How to debug slow lambda response times
How to debug slow lambda response timesHow to debug slow lambda response times
How to debug slow lambda response timesYan Cui
 

Mais de Yan Cui (20)

How to win the game of trade-offs
How to win the game of trade-offsHow to win the game of trade-offs
How to win the game of trade-offs
 
How to choose the right messaging service
How to choose the right messaging serviceHow to choose the right messaging service
How to choose the right messaging service
 
How to choose the right messaging service for your workload
How to choose the right messaging service for your workloadHow to choose the right messaging service for your workload
How to choose the right messaging service for your workload
 
Patterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdfPatterns and practices for building resilient serverless applications.pdf
Patterns and practices for building resilient serverless applications.pdf
 
Lambda and DynamoDB best practices
Lambda and DynamoDB best practicesLambda and DynamoDB best practices
Lambda and DynamoDB best practices
 
Lessons from running AppSync in prod
Lessons from running AppSync in prodLessons from running AppSync in prod
Lessons from running AppSync in prod
 
Serverless observability - a hero's perspective
Serverless observability - a hero's perspectiveServerless observability - a hero's perspective
Serverless observability - a hero's perspective
 
How to ship customer value faster with step functions
How to ship customer value faster with step functionsHow to ship customer value faster with step functions
How to ship customer value faster with step functions
 
How serverless changes the cost paradigm
How serverless changes the cost paradigmHow serverless changes the cost paradigm
How serverless changes the cost paradigm
 
Why your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSyncWhy your next serverless project should use AWS AppSync
Why your next serverless project should use AWS AppSync
 
Build social network in 4 weeks
Build social network in 4 weeksBuild social network in 4 weeks
Build social network in 4 weeks
 
Patterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applicationsPatterns and practices for building resilient serverless applications
Patterns and practices for building resilient serverless applications
 
How to bring chaos engineering to serverless
How to bring chaos engineering to serverlessHow to bring chaos engineering to serverless
How to bring chaos engineering to serverless
 
Migrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 stepsMigrating existing monolith to serverless in 8 steps
Migrating existing monolith to serverless in 8 steps
 
Building a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQLBuilding a social network in under 4 weeks with Serverless and GraphQL
Building a social network in under 4 weeks with Serverless and GraphQL
 
FinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economyFinDev as a business advantage in the post covid19 economy
FinDev as a business advantage in the post covid19 economy
 
How to improve lambda cold starts
How to improve lambda cold startsHow to improve lambda cold starts
How to improve lambda cold starts
 
What can you do with lambda in 2020
What can you do with lambda in 2020What can you do with lambda in 2020
What can you do with lambda in 2020
 
A chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage awayA chaos experiment a day, keeping the outage away
A chaos experiment a day, keeping the outage away
 
How to debug slow lambda response times
How to debug slow lambda response timesHow to debug slow lambda response times
How to debug slow lambda response times
 

Último

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentPim van der Noll
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality AssuranceInflectra
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersNicole Novielli
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Scott Andery
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterMydbops
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Último (20)

DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native developmentEmixa Mendix Meetup 11 April 2024 about Mendix Native development
Emixa Mendix Meetup 11 April 2024 about Mendix Native development
 
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance[Webinar] SpiraTest - Setting New Standards in Quality Assurance
[Webinar] SpiraTest - Setting New Standards in Quality Assurance
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
A Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software DevelopersA Journey Into the Emotions of Software Developers
A Journey Into the Emotions of Software Developers
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
Enhancing User Experience - Exploring the Latest Features of Tallyman Axis Lo...
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Scale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL RouterScale your database traffic with Read & Write split using MySQL Router
Scale your database traffic with Read & Write split using MySQL Router
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Introduction to Aspect Oriented Programming

Notas do Editor

  1. Definition: A Cross-Cutting Concern is a concern your application needs to address that is unrelated to your application’s problem domain, and ‘cuts across’ other concerns. Examples: Typically non-functional requirements such as tracing, logging, persistence, transaction control, security, error handling Cross-cutting concerns are usually difficult to decompose from the rest of the system and results in: tangled code, concerns are interwoven with each other in a module scattered code, concerns are dispersed over many modules high coupling Addressing cross-cutting concerns usually means adding boilerplate code to your application, increasing both the size and complexity of your code, and the blast radius of any change that are not related to the problem domain, e.g. changing the persistence media.
  2. Definition: A Cross-Cutting Concern is a concern your application needs to address that is unrelated to your application’s problem domain, and ‘cuts across’ other concerns. Examples: Typically non-functional requirements such as tracing, logging, persistence, transaction control, security, error handling Cross-cutting concerns are usually difficult to decompose from the rest of the system and results in: tangled code, concerns are interwoven with each other in a module scattered code, concerns are dispersed over many modules high coupling Addressing cross-cutting concerns usually means adding boilerplate code to your application, increasing both the size and complexity of your code, and the blast radius of any change that are not related to the problem domain, e.g. changing the persistence media.
  3. Poor traceability – multiple concerns in the same module breaks linkage between requirement and its implementation, making it harder to understand what a piece of code is doing to address the problem domain. Lower productivity – developers are spending too much time and attention to peripheral issues rather than the problem domain. Less code reuse – boilerplate code propagated through cut and paste… no code reuse here! Harder refactoring – changing requirements means touching many modules for a single concern.
  4. Which finally brings us to aspect oriented programming, and I’ll give you a second to read this quick definition from Wikipedia.
  5. Take the ‘GetBookById’ method we ended up with earlier, now let’s give ourselves a magic hat and let the hat devour that ugly piece of code, and with a touch of AOP magic we’ll get back a cleaner, more elegant and readable version of the ‘GetBookById’ method. Under the hood, the two versions are the same, both log when they enter and exit the method, and both log any exceptions, also both versions of the code perform validation against the ‘id’ parameter to make sure that it’s not a default Guid.
  6. Whist this is useful, it will still cause a lot of clutter when you have to apply the same set of attributes to many methods. But worry not, another feature of AOP is the ability to multicast the same aspects into many places in your code, this feature is called Point Cut.
  7. To summarize, AOP allows you to centralize your implementation of cross-cutting concerns. It gives you a nice framework to intercept method calls and inject new behaviour with little change to your code. Once you’ve modularized your code that deal with the cross-cutting concerns, you are able to reuse them in other projects. This lets you write more reusable code and cleaner code.
  8. That’s all very nice, but why should you care about writing reusable and clean code? What do you get out of it?
  9. Well, for one, you end up writing less code, and therefore you will need to read less code too. The code that you end up reading will be more concise and easy to understand as they’re no longer convoluted by cross-cutting concerns. As you reduce the complexity of your code, it becomes more maintainable too.
  10. Writing fewer lines of code means less chance for us to get it wrong, and therefore fewer defects in our code. You have to less boilerplate code, and that makes your work more interesting, and therefore you pay more attention to what you do. So all and all, you get a healthy boost of productivity when you take advantage of what AOP has to offer!
  11. Now that you have a rough idea of what AOP is and how it can help you, let me help you get a sense of how you go about using it in practice. Before we do, let me give you a 2-minute crush course on the terminologies used in AOP.
  12. Join points are places in your code where an aspect can be inserted, for example, before and after a method call, when a method excepts, or when field or property is being accessed. An advice is a piece of code that can be injected at join points to add new behaviour. This is the boilerplate that you had taken out from your code so that you can encapsulate it into an aspect and then inject it in whilst keeping your code pretty. A point cut is a set of join points where an advice can be applied. It can be attribute drive, like the earlier example of ‘GetBookById’ method where we applied the two attributes to the method. Or it can be filter driven, like the second example where we applied the attributes to the class instead and targeted methods that met our criteria. When a point cut is matched, advice can be executed. An aspect contains point cuts and advice, it is to AOP what class is to OOP, whereas classes holds methods and properties, aspects holds point cuts and advice. Weaving is the process of taking the advice and injecting them into the point cuts in the core component and compose the final result.
  13. AOP and OOP are not mutually exclusive; AOP is in fact complimentary to OOP and help you become a better OOP developer by helping you enforce some important design principles of OOP. Unlike OOP, functional programming or declarative programming, which are general purpose paradigms aimed to solve most of the programming problems we face, and all competing to be the core paradigm of a language. AOP on the other hand, is a paradigm which attempts to solve one very specific problem. AOP and OOP both encourage code modularization and encapsulation, which leads to better code reusability and maintainability. The difference between the two paradigms come in the form of WHAT they modularize on: - OOP modularizes on basis of real world entities AOP modularizes on basis of functionalities
  14. For those of you who aren’t familiar with the SOLID principles, they stand for: Single responsibility principle: an object should have only one responsibility Open/Close principle: objects should be open for extension, but closed for modification Liskov substitution principle: objects should be replaceable with instances of their subtypes without altering the correctness of that program Interface segregation principle: many specific interfaces are better than one general purpose interface Dependency inversion principle: one should depend upon abstraction rather than implementations These are 5 principles that can help you create more maintainable software with fewer defects. Most of you should be familiar with the dependency inversion principle already because that’s the problem that IoC frameworks solve and IoC frameworks are extremely popular nowadays. You can use AOP to help you better adhere to these principles, for instance, by using AOP to remove the cross-cutting concerns from your core program it becomes easier for you to follow the single responsibility principle. Similarly, using point cut and multicast attribute as I demonstrated earlier, you are able to inject new behaviour into existing classes without modifying them, hence not breaking the open/close principle.
  15. So hopefully that’s sufficient evidence for you to want to give AOP a go, but in terms of actually start doing some aspect-oriented programming you have quite a number of different options, including: Dynamic proxies with IoC frameworks - Functional programming using higher-order functions - Code generation using tools like T4 - Dynamic languages using their meta-programming capabilities - Static weaving, by modifying the MSIL in a post-compilation process
  16. Dynamic proxies are supported in IoC frameworks such as Castle or Spring.net, and here’s a simple example of a logging interceptor that logs the entry and exit of a method and any unhandled exceptions that bubbles out of the method.
  17. If you are using a dependency injection framework already, and all you want is to be able to intercept method calls and inject additional behaviour, then dynamic proxies represent the easiest way for you to adopt AOP in your project right away. Also, some frameworks provide built-in aspects such as the logging aspect I showed you earlier. Most such frameworks also allow you to configure aspects through configuration files, making it easier for you to make changes in a live environment without having to compile and deploy any code changes.
  18. However, dynamic proxies only offer a limit set of AOP’s features, and if you’re not already using a dependency injection framework, adopting it into an existing code base will require a significant amount of work and change. There are also a number of restrictions, dynamic proxies do not work on static, or non-public methods, and they do not work on fields, properties or events. Since aspects are applied at runtime, there is a higher runtime overhead than there is with build-time AOP frameworks. However, this is only likely to cause a noticeable impact on your application’s performance if you’re generating large numbers of dynamic proxies. The bigger drawback is the lack of build-time verification to make sure that you’re using the aspects incorrectly. But for me, the biggest problem with using dynamic proxies is that it only works if your objects are instantiated using the container. This can cause major confusion to the consumers of your code, because when they instantiate the instances themselves the injected behaviours will not be present. That is not always clear, and without looking into your code and your container configuration it’ll be difficult to figure which behaviours were injected and which weren’t. This is one area where hard-to-detect bugs can creep in and you won’t see it until things blow up at runtime! Nasty stuff!
  19. Because IoC frameworks are so commonly used these days, and a lot people have their first experience with AOP through the use of dynamic proxies, many people have associated dependency injection with AOP. Well, I’m here to tell you that the two are not the same, at all! Dependency injection is a design pattern that addresses the problem of writing loosely-coupled components together, and helps you enforce the practice of design by contract. You program to an abstraction/interface rather than an implementation, and instead rely on the container to provide the concrete implementation at runtime. AOP on the other hand, addresses a very different issue: cross-cutting concerns as I showcased earlier. Dependency injection became associated with AOP because it just happens to be in a convenient place to allow users to inject new behaviours to existing code base transparently.
  20. That is the essence of the memoization technique, which I’ll show you right here with this bit of F# code. Don’t worry about the syntax; the important thing to note here is that this function takes another function as input, and use a dictionary to cache results before returning a modified version of the original function. …DEMO…   The memoize function is simple and yet effective, however, it breaks down when you use it with a recursive function. It’s not hard to fix it, but the whole AOP experience here is just not quite transparent and unobtrusive as you’d like.
  21. The advantage of doing AOP in functional programming is that you don’t require any external dependencies as you do with dynamic proxies and static weaving, instead you write everything as higher-order functions in the language you’re already familiar with.
  22. But, as I have demonstrated with recursive function, if you want to use the memoized version of the function f everywhere in your code, you’ll need to modify all the places where f is being used. Also, there’s no support for matching rules that lets you apply the same aspect to multiple functions in bulk. And when you want compose different aspects together, i.e. combining multiple higher-order functions, you’ll need to do it manually which is a task that’s easier said than done.
  23. A static weaving solution AOP usually involve a three phase implementation: Aspectual decomposition – based on requirements, identify concerns as either primary (problem domain) and cross-cutting Concern implementation – code each concern separately, primary (OO) and cross-cutting (AO) Aspectual recomposition – use aspect weaver to weave the separately implemented code together into a final system