Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
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”
- w...
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 p...
 AOP is complementary to OOP
 AOP targets a specific problem
 Code modularization
 OOP – Real world objects
 AOP – Fu...
 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...
 Disadvantages
 Significant change to base code required to adapt
 Limited AOP features
 Do not work on static, non-pu...
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 sepa...
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
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
Introduction to Aspect Oriented Programming
Upcoming SlideShare
Loading in …5
×

4

Share

Download to read offline

Introduction to Aspect Oriented Programming

Download to read offline

Introduction talk to Aspect Oriented Programming

Related Books

Free with a 30 day trial from Scribd

See all

Related Audiobooks

Free with a 30 day trial from Scribd

See all

Introduction to Aspect Oriented Programming

  1. 1. Yan Cui
  2. 2. Server-side Developer @ “Our mission is to build fun games and game apps that people can play, anywhere, anytime.”
  3. 3.  Overview  Cross-Cutting Concerns  AOP  What’s in it for you  AOP  Terminologies  AOP and OOP  Solutions  Q&A
  4. 4. The PROBLEM…
  5. 5. Image by Mark RohdeImage by Mike Rohde Cross-Cutting Concerns
  6. 6. Function Requirements Non-Functional Requirements Production Code =+
  7. 7.  Cuts across multiple abstractions  Difficult to decompose  High-coupling  Boilerplate code
  8. 8.  Code tangling and scattering  Poor traceability  Lower productivity  Less code reuse  Harder refactoring
  9. 9. The SOLUTION…
  10. 10. “AOP is a programming paradigm which aims to increase modularity by allowing the separation of cross-cutting concerns” - wikipedia
  11. 11. Coding is HARD AOP makes it EASY
  12. 12. Image by Mark Rohde AOP
  13. 13.  Centralize concerns implementation  Intercept method calls  Inject new behaviour  More reusable code  Cleaner code
  14. 14. What’s in it for YOU?
  15. 15.  Write less code  Read less code  More concise and easy to understand  More maintainable
  16. 16.  Fewer code =  Less boilerplate code  More interesting work  Increased attention  More PRODUCTIVITY! FEWER DEFECTS!
  17. 17. Diving a little deeper…
  18. 18.  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
  19. 19.  AOP is complementary to OOP  AOP targets a specific problem  Code modularization  OOP – Real world objects  AOP – Functionalities
  20. 20.  Help you S.O.L.I.Dify your code  Single responsibility  Open/close
  21. 21.  You can do AOP via:  Dynamic Proxies  Functional Programming  Code Generation  Dynamic Languages  Static Weaving
  22. 22. AOP via...
  23. 23.  IoC framesworks (Castle, Spring.Net)  Dynamic interceptors
  24. 24. Image by Mark Rohde Dynamic Proxies
  25. 25.  Advantages  Can use existing DI framework  Some frameworks provides built-in aspects  Aspects can be configured after build
  26. 26.  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
  27. 27. Class, is AOP the same as Dependency Injection? NOOOO Sir!!
  28. 28. AOP via...
  29. 29. Image by Mark Rohde Functional Programming
  30. 30.  Advantages  No external dependencies
  31. 31.  Disadvantages  Requires modification to every function  No support for matching rules  Manual aspect composition
  32. 32. AOP via…
  33. 33.  T4, CodeSmith Tools
  34. 34.  Advantages  Easy to generate complex source code
  35. 35.  Disadvantages  Input is usually XML  Cannot inject new behaviour to existing code
  36. 36. AOP via…
  37. 37. Image by Mark Rohde Dynamic Languages
  38. 38.  Advantages  Meta-programming is easy
  39. 39.  Disadvantages  Switching to a dynamic language can be scary  No (limited) Visual Studio tooling
  40. 40. AOP via…
  41. 41.  PostSharp, AspectJ  Uses low-level MSIL transformation  Compile time
  42. 42. Aspect Decomposition Aspects Core program Aspect Recomposition Requirements Final System
  43. 43.  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
  44. 44. Image by Mark Rohde PostSharp
  45. 45.  Advantages  Most complete support of AOP features  Aspect usage is verified at build time  Better runtime performance
  46. 46.  Disadvantages  Increased build time  New to many developers
  47. 47. PostSharp Training @ SkillsMatter, London January 19-20, 2012 http://www.sharpcrafters.com/training
  48. 48. jobs@iwi.com Thank You! Yan Cui @theburningmonk
  • JasonNguyen12

    Jan. 30, 2016
  • ShiwaliSonwani

    Apr. 26, 2015
  • harish3742

    Feb. 27, 2015
  • raghavproteas

    Oct. 6, 2012

Introduction talk to Aspect Oriented Programming

Views

Total views

11,815

On Slideshare

0

From embeds

0

Number of embeds

2,310

Actions

Downloads

412

Shares

0

Comments

0

Likes

4

×