I always looked at the relationship of a handler to a command as 1:1.
In practice, this can add up to a lot of thin handlers, so I like the idea of having a handler with multiple methods responsible for handling a command. For example:
class AddTaskCommand {...}
class CompleteTaskCommand {...}
class TaskCommandHandler
{
public function addTaskCommand(AddTaskCommand $command) {...}
public function completeTaskCommand(CompleteTaskCommand $command) {...}
}
Because of this, the shared command handler can have dependencies used to complete both commands:
class TaskCommandHandler
{
public function __construct(TaskRepository $repository) {...}
}
At the very least, Sergeant should support something along these lines.
Started thinking about this after watching: http://www.youtube.com/watch?v=3uV3ngl1Z8g&t=32m58s
I always looked at the relationship of a handler to a command as 1:1.
In practice, this can add up to a lot of thin handlers, so I like the idea of having a handler with multiple methods responsible for handling a command. For example:
Because of this, the shared command handler can have dependencies used to complete both commands:
At the very least, Sergeant should support something along these lines.
Started thinking about this after watching: http://www.youtube.com/watch?v=3uV3ngl1Z8g&t=32m58s