Sponsor: Do you build complex software systems? See how NServiceBus makes it easier to design, build, and manage software systems that use message queues to achieve loose coupling. Get started for free.
In a couple previous posts I’ve discussed using Query Objects instead of Repositories and the Mediator pattern. I find creating query objects being used with the command pattern much cleaner than polluting repositories with a ton of query methods. The concept is nothing new as many people already use the command pattern in the context of executing commands/behavior following CQRS. However, there is nothing wrong with using the same patterns for the query side. I’ve been using my own home grown solution of the mediator pattern in a few different projects but had nothing really formalized. I was thinking about creating a simple library until I stumbled upon MediatR created by Jimmy Bogard. It is incredibly simple and only has one dependency, CommonServiceLocator. The Github repo has a good set of docs and some examples with different dependency injection containers.
Service Locator? That can’t be good!?
Thankfully MediatR 2.0 removed this dependency and is now released as of I think a couple months ago. I’ll update this post along with blogging about MediatR and NancyFX.
Cool. I’m going to add to this or feel free to send a PR. https://github.com/jchannon/LayerAllTheThings Looking forward to the blog post
Pingback: Thin Controllers with CQRS and MediatR
Pingback: Identify Commands & Events - CodeOpinion
Pingback: Validating Commands
Pingback: Mediator Pattern with Hangfire - CodeOpinion