introduction to aspect oriented programming with cirrus and delphi prism jim mckeeth | podcast at...
TRANSCRIPT
![Page 1: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/1.jpg)
Introduction toAspect Oriented Programming with Cirrus and Delphi Prism
Jim McKeeth | Podcast at Delphi.org
![Page 2: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/2.jpg)
2
AgendaWhat is AOP?Why AOP?Two AOP ParadigmsThe Cirrus FrameworkExamplesDebuggingOther AOP FrameworksFuture
2
![Page 3: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/3.jpg)
3
??What is What is
Aspect-OrientedAspect-OrientedProgramming?Programming?
![Page 4: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/4.jpg)
4
A Paradigm ShiftAspect-Oriented
programming
is to
Object-Oriented
programming
Object-Oriented
programming
is to
Procedural
programming
as
Why do we need a new paradigm?
I can do this already!
Won’t it be slower / harder
to debug?
![Page 5: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/5.jpg)
5
A DefinitionA programming paradigm that increases modularity by enabling
improved separation of concerns. This entails breaking down a program
into distinct parts allowing the separation of cross-cutting concerns.
Think of it as
Super-Encapsulation
![Page 6: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/6.jpg)
6
Think of it as
Super-Encapsulation
![Page 7: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/7.jpg)
7
What is a Concern?•A distinct and cohesive area of functionality
• Examples:
•Business logic
•User interface
•Database access
•Error handling
•Logging
•Threading
•Transactions
•Security
•Exception handling
Secondary requirements, but often the bulk of our code!
![Page 8: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/8.jpg)
8
What Makes a Concern Cross-Cut?
??Business logic
Erro
r han
dlin
gThread lockingUser Interfa
ce
![Page 9: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/9.jpg)
9
The Principles of OOD•SRP The Single Responsibility Principle - A class
should have one, and only one, reason to change.
•OCP The Open Closed Principle You should be able
to extend a classes behavior, without modifying it.
•LSP The Liskov Substitution Principle Derived classes
must be substitutable for their base classes.
•ISP The Interface Segregation Principle Make fine
grained interfaces that are client specific.
•DIP The Dependency Inversion Principle Depend on
abstractions, not on concretions.
http://butUncleBob.com/ArticleS.UncleBob.PrinciplesOfOod
Robert C. Martin “Uncle Bob”
www.objectmentor.combutUncleBob.com
![Page 10: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/10.jpg)
10
Two AOP Paradigms
•Pre-Compile / At-Compile•Decorating the code with the aspects before compilation
(method used by Cirrus)
•Concerns are woven in during compilation.
•Post-Compile•Weave the advice in after compilation via Point-Cut
definitions (method used by AspectJ)
•Allows modification of existing functionality without
modifying code.
![Page 11: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/11.jpg)
11
![Page 12: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/12.jpg)
12
Bank Transfermethod TBank.Transfer(fromAccount, toAccount: TAccount; amount:
Integer);
begin
if fromAccount.Balance < amount then
begin
raise new EInsufficientFundsException();
end;
fromAccount.withdraw(amount);
toAccount.deposit(amount);
end;
![Page 13: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/13.jpg)
13
With Security
13
With Security
![Page 14: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/14.jpg)
14
With Logging . . . .
14
With Transactions
With ThreadingW
ith ???
![Page 15: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/15.jpg)
15
With Cirrus AOP
15
![Page 16: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/16.jpg)
16
Cirrus Fundamentals•Add reference to RemObjects.Oxygene.Cirrus.
• Not necessary to deploy.
•Aspects must be in a separate assembly.• Also not necessary to deploy.
•Aspects woven in at compile time.
•Cirrus exists as a series of Interfaces (callbacks).
•Aspects are applied via Attributes with the aspect: prefix.
![Page 17: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/17.jpg)
Demo Time
![Page 18: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/18.jpg)
18
More on Cirrus•Cirrus Overview
•prismwiki.codegear.com/en/Cirrus_Overview
•Common Aspect Library
•http://code.remobjects.com/p/prismaspects/
•RemObjects Blog
•Blogs.RemObjects.com/blogs/
•My Blogs
•Delphi.org
•DavinciUnltd.com
18
![Page 19: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/19.jpg)
19
Other AOP Frameworks•For Delphi Win32
• MeAOP in MeSDK
•code.google.com/p/meaop/
•Other .NET options•
•PostSharp.org
•
•SpringFramework.net
•C++
• AspectC.org
•Java
• eclipse.org/AspectJ
19
![Page 20: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/20.jpg)
20
??The
Futureof AOP
![Page 21: Introduction to Aspect Oriented Programming with Cirrus and Delphi Prism Jim McKeeth | Podcast at Delphi.org](https://reader034.vdocuments.us/reader034/viewer/2022052321/5513b9145503464b298b45ec/html5/thumbnails/21.jpg)
21
Contact Me•Jim McKeeth
• Twitter.com/JimMcKeeth
• FriendFeed.com/JimMcKeeth
• Delphi.org
• DavinciUnltd.com/Code/Cirrus/ Get the slides