Thursday, 28 February 2019

Command Handling Pattern Part 1

The Problem to be Solved


I've spent a lot of time over the past few years writing line-of-business applications in various industries, and I never felt entirely comfortable with how I structured business logic. I generally used entity-based services - e.g. a Product Service that operates on a Product entity - and the problem that I saw again and again with this approach is that the service ends up a bloated, unfocused mess: the 'God' service that knows and does everything.

So I went searching for alternatives and decided to start using a Command Handling Pattern. The central idea is that a business process that needs to be performed (i.e. writes not reads) is represented by a Command (this is similar to, but not exactly the same as, the traditional Command Pattern).

I'm planning on writing a series of posts to explore how my ideas evolved from a fairly simple pattern to a more complex solution taking ideas from the Chain of Responsibility Pattern.

Next time I'll go into the first step on this journey. Watch this space!