Hi,
I have a question regarding best practice:
I would like to split up EventHandling of Child-Entity-specific events into these Entities and keep the AggregateRoot clean of that handling as much as possible. We already keep CommandHandling out in a separate Component, so we basically have left the methods applying the events and the @EventSourcingHandler annotated methods changing the state.
We have an Aggregate and a related LifeCycle Entity (Annotated @AggregateMember) within it. When a Command is published that concerns the LifeCycle (log operating hours), we would like to call it like that:
`
Aggregate<SomeAggregate> user = repository.load(command.getSomeAggreagteIdId());
user.execute(aggregate ->
aggregate.getLifeCycle()
.logManualOperatingHours(
aggregate.getAggregateId(),
command.getLogDate(),
command.getNewOperatingHours(),
command.getComment(),
submittedBy
)
);
`
Is that considered good practice? Would it be better to have the method logManualOperatingHours in the AggregateRoot and just the @EventSourcingHandler inside the LifeCycle-Entity?
Kind regards,
Lars Karschen