Aspect Oriented Programming in Delphi
Posted by jpluimers on 2015/06/24
I’ve been doing Aspect Oriented Programming (AOP) in .NET for a long while, mostly using PostSharp LAOS as that was the first AOP .NET library I encountered (5 years ago it became PostSharp 2.0, now it is already at its 10th anniversary!).
AOP allows you to perform separate of concerns (SoC) in your application, especially in the area of cross-cutting concerns like for instance logging, authorization, monitoring, etc.
It took a while in Delphi to allow for AOP, but the TVirtualMethodInterceptor (that introduced in Delphi 2010) can be used to do AOP (only for Virtual Methods, which is still way better than having no AOP at all).
The code requires a lot of manual labor. so I was glad that DSharp (a great library by Stefan Glienke – one of the leading Spring4D contributors) contains a nice wrapper around TVirtualMethodInterceptor so you can use AOP in an attribute based fashion.
Nick Hodges recorded a good introductory video on AOP in Delphi with slides and demo code:
- Youtube Video on AOP in Delphi using DSharp.
- Demo code and slides at http://bit.ly/NickAOP.
Note that besides DSharp, also MeAOP and Infra provided support for AOP in Delphi, but these haven’t had updates since 2010.
–jeroen
via: AOP on .NET – PostSharp.






Leave a comment