Your SlideShare is downloading. ×
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Aspect oriented programming
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Aspect oriented programming

1,296

Published on

AOP is a way of making code easier to write and work with by extracting cross cutting concerns into small easily reusable code that is applied with attribututes. This session looks at that and the …

AOP is a way of making code easier to write and work with by extracting cross cutting concerns into small easily reusable code that is applied with attribututes. This session looks at that and the various options available to us, from free items to commercial offerings like PostSharp.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,296
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
28
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Aspect-oriented programming
    robertmaclean
    www.sadev.co.za ∞ @rmaclean ∞ robert@sadev.co.za
  • 2. Agenda
    What, when, why of AOP?
    How is it implemented in PostSharp and how does it work?
    Alternatives to PostSharp
    Looking to the future
    Discussion
  • 3. Every project has “boring” code
    source: Microsoft Application Architecture Guide, 2nd Edition
  • 4. AOP Details
    Goal to make cross cutting concerns easy to implement and focus on business code
    Xerox PARC in 2001
    AspectJ
    Many implementations now days
    AKA: AOSD
  • 5. Scenario code – simple prime calculator
    Customer says it’s wrong. We need logging to diagnose…
  • 6. Let’s add logging – trace input & output
    Easy to miss some places
    Lots of repetition of code
    Need to teach this
    Not portable
    5 extra lines of code
  • 7. What about some procedural help?
    Not junior friendly
    Need 1 per signature
    15 extra lines of code
  • 8. So how does aspects solve that?
    Feel like you are missing something?
    1 extra line of code
  • 9. Demo time…
  • 10. Under the hood
    Source: .NET Reflector 6.8
    IL modified
  • 11. Many ways to implement AOP in .NET currently
    Popular:
    IL Weaving @ compile or JIT
    PostSharp & Mono.Cecil
    Less:
    Hooking into .NET profiler API
    Proxies
  • 12. IL Weaving
    .cs or .vb code
    IL (pure)
    PostSharp
    IL (Merged)
  • 13. Hooking the profiler
    Disadvantages
    • Poor performance
    • 14. Exceptionally complex
    • 15. Not designed for this
    Advantages
    • Nothing is safe from it’s power
    • 16. Solves some fringe cases (i.e. mocking static methods)
    Application
    COM API
    CLR
    Profiler
    Environmental
  • 17. Proxies
    Proxied
    Normal
    Method Call
    Method Call
    Proxy
    Object
    Disadvantages
    • Complex with ContextBoundObject
    • 18. Perf is worse than IL weaving
    Advantages
    • Using DI it can be easier
    • 19. Perf is better than .NET profiler
    Object
  • 20. Future: Post Roslyn Theory
    Roslyn
    Next version of C#/VB “compiler”
    Written in managed code
    Available as a service
    Post Roslyn
    Insert new language semantics
    Approach the AspectJ style
  • 21. Summary
    AOP
    Way to untangle cross cutting concerns out of business code
    Great re-use
    Can be easy to use (depending on implementation)
    Many options to do this!
  • 22. Questions & Discussions

×