Archives For SRP


Commands can be complicated to test and reuse. In a previous post, I demonstrated how to build reusable testable Queries, in this series of posts I will show you how to build commands which can be tested and reused.

This small yet powerful interface can help you build commands which respect SOLID principles like the Single Responsibility Principal (SRP), the Open/Closed Principle (OCP) and the Dependency inversion principle (DIP).

public interface IModelCommand<in TModel>
{
    void Apply(TModel model);
}

Continue Reading…


Query encapsulation can become quite empowering. For instance, query objects can be decorated, extended and reused. They allow us to implement concepts like targeted caching or user defined queries. They even allow us to execute the same query on two different data sources.

In part 2 of this series, we will be looking at how we can leverage the IModelQuery interface to enable us to reuse queries. Continue Reading…


Queries are complicated to test and nearly impossible to reuse. In systems of all sizes they get duplicated,  modified and augmented to the point where we are afraid to modify them. They are essentially questions about data that generate information upon which we can act. They should be reusable. They should be predictable and above all, they should be testable.

Continue Reading…