Let's say I am designing a TODO application and therefore have an aggregate root called
Task. The business requires to keep a list of
TaskLogEvent that provides them with a history of how the task changed over time. As the
Task may have hundreds of these events, I will model this
TaskLogEvent as a separate aggregate root (I do not want to load these elements every time and I am not using any lazy loading mechanism).
Now anytime I want to do
task.complete() or any other opration modifying the
Task I want to create a new
TaskLogEvent. I have these options:
- Design a domain service that will make all changes to
Taskand create the event. Every comunication with
Taskwould have to get through this service.
TaskLogEventRepositoryto any method in
Taskso that the
Taskitself can create the Event and save it into the repository.
- Let an application service handle this. I don't think that is a good idea.
What would be the ideal solution to this situation? Where did I make mistake in my thinking process?