Principles of Aspect Oriented Programming in C#

    01 June 2015

    Aspect Oriented Programming (AOP) has been around for a long time. It is a powerful concept that allows for the separation of “crosscutting” concerns that has always been widely misunderstood by developers and managers alike in my experience. This confusion has largely been due to the mismatch between AOP theory, terminology, and implementation. Recently, I have seen a renewed interest in it, and I hope this article can help to demystify some of the confusions.

    Bad Coupling with Constructor Injection

    20 August 2014

    In previous posts, I started to explain the difference between Dependency Injection (DI) and a simple factory. To leverage more of the potential of DI, I gave an example of using constructor injection and contrasted that with setter injection. Like all things, too much of a good thing can have horrible consequences. Hopefully, this post can help you to identify when things are going wrong.

    Setter Injection

    12 August 2014

    In my last post, I explained some of the differences between Dependency Injection (DI) and the factory pattern. I also gave an example of how constructor injection could be used to leverage the DI framework's ability to manage dependencies of dependencies. While constructor injection is my personal preferred way of doing it, there is an alternative. You could also use setter injection.

    Factories and Dependency Injectors

    14 July 2014

    It seems that over the years, many people have accepted that Dependency Injection (DI), which is sometimes called Inversion of Control (IoC), is a "good thing" and that they should be "doing it." But, few of those that I talk to seem to know why that is. And, fewer still can tell you the difference between the Factory Pattern and DI. This is usually an indicator of how they (mis)utilize their DI framework. Many of the implementations that I have seen use it as a glorified factory. But, DI is a special implementation of the factory pattern that can do so many more things to help improve the structure of your code and improve testability than just serving out objects. The relationship between the factory pattern and DI is like the relationship between rectangles and squares. All squares are rectangles, but a rectangle is not necessarily a square. Just like all DI frameworks follow the factory pattern, but a factory is not necessarily a DI container.