Just trying to get some opinions on whether or not CommandHandlers can/should communicate with other CommandHandlers.
Here is a simple case I just ran into. I have a ChangePasswordCommandHandler who's command looks like the following:
public class ChangePasswordCommand : Command
{
public string Email { get; }
public string OldPassword { get; set; }
public string NewPassword { get; set; }
}
So, inside the handler I need to validate the users olds password, so as I see it I have three options:
- dispatch out a call to my ValidateCredentialsCommandHandler.
- factor out some of the validation logic into a service that both handlers can use.
- have the calling process do this check first, but now business logic is leaking outside of my domain layer.
I'm running into a few technical issues with dispatching to other handlers mostly b/c i'm using a transaction per-web request, so i have two transactions trying to contend.
Thoughts?