Wednesday, 16 September 2015

The magic of Aspect Oriented Programming with PostSharp

In this video tutorial, I explain what Aspect Oriented Programming (AOP) is all about, the issues it solves and the benefits of using it.
I demonstrate it with PostSharp, the best framework for implementing aspects and integrating them with your solution.

Quoting PostSharp, it allows developers to eradicate boilerplate by offloading repeating work from humans to machines. PostSharp contains ready-made implementations of the most common patterns and gives you the tools to build automation for your own patterns..

In my demo, I show how to use those ready-made implementations, as well as get started with your own custom ones (best viewed in full screen, for the code screencast).

Get the Powerpoint file here.
Get the demo project here.

Benefits of Aspect Oriented Programming

As I explain, in the video, the power of Aspect Oriented Programming, is mostly in:
  • Reusing repetitive boilerplate code across your project.
  • Avoiding errors and bugs.
  • Addressing cross-cutting concerns all over the place in an encapsulated way.
  • Keeping your code readable, maintainable, testable, well formatted, with less clutter, while still attending all the above.

Why  PostSharp

  • PostSharp is the most advanced AOP framework. 
  • It differs from other frameworks, by using the technique of IL-weaving.
  • It provides a wide, easy to use, infrastructure of components you can easily integrate into your code and get started building your own aspects,
  • It comes with a number of built-in customizable aspects for the most common cases, such as implementing INotifyPropertyChanged or logging. Those are extremely easy to apply across your entire solution.
  • It is well maintained, supported, documented, kept up-to-date.
  • Because it's transparent. sizeOf(Code).Matters();
See more on the PostSharp site, download it here (online documentation here).

Keep your spaghetti neat!

Additional resources

Check out this great AOP introduction by Donald Belcham

And check out this great tutorial about bacon weaving!


  1. I love this blog . This is one of the best blog i ever seen. It's all about what i'm searching for. I love to read this blog again and again . Every time i enter this blog i get something new. This blog inspire me to write new blog. I write a blog name It's about sql,c#,net etc

  2. Simply having the desire to perform magic and be a great magician is not enough - one should have the determination and the willingness to invest a lot of time and effort to practice performing tricks so that one can master the art of making people believe in illusions.magic tickets

  3. Coffee is the starter of the day for more than half of the people. Many people buy a cup of coffee first from any coffee shop and then start their day at work. It costs them much if they calculate it. But now, there is an easy way to make coffee at home by buying the best coffee maker machine from market by checking the list of best coffee makers.

  4. Thanks for a very interesting blog. What else may I get that kind of info written in such a perfect approach? I’ve a undertaking that I am simply now operating on, and I have been at the look out for such info. find out details