I’m working on a .NET Core application using the CQRS pattern with MediatR, and I’m confused about the real difference between a Handler and a Service.
Both seem to contain business logic, but the usage pattern looks different:
Services are reusable classes used across multiple areas.
Handlers execute one specific command/query (ex: CreateUserHandler, UpdateOrderHandler).
My doubts:
Should business logic be placed inside the Handler directly, or inside a Service and called by the Handler?
When is it appropriate to create a Service instead of putting everything inside a Handler?
Is it considered bad practice if my handlers become big?
Do services still make sense if I’m using strict CQRS with MediatR?
I want to keep my architecture clean and follow best practices, so what’s the recommended approach?