Reputation: 1
I'm thinking of applying the CQS pattern to my new project. I just wanna separate my queries and commands in a simpler way (I don't need fully CQRS approach). I don't want to put them all in a one class.
I have a couple of questions:
Because I'm thinking of creating an interface called IMovieAPIStrategy, and implementing its concretes. Then use this interface in any query or command handlers. Is that correct approach?
Upvotes: 0
Views: 489
Reputation: 4346
The query/command handlers themselves can always take their own dependencies via the constructor with IoC. So if you have some shared logic API you want to reuse, you can inject that into the handler. The big power with using this pattern is the decorators you can add because you can code cross-cutting concerns in a single class that applies to all handlers and not have to redo that logic hundreds of times. You just get it for free, essentially (which MediatR can help with).
Upvotes: 0