For an early implementation of the fes package, we went for a Java-like inheritance approach for the updating of event store models. Each one required 'extending' the fes.BaseEntity and implementing the fes.Entity interface to support copying and state mutation.
Since our Golang expertise has grown, and we have more experience with using event sourcing, this clone-mutate approach has turned out not to be the best idea. It complicates the code a lot, with few (if any) benefits.
To simplify the codebase, we should probably remove the current clone-mutate approach, use cache.GetAggregate for everything, and ensure that ApplyEvent(entity, events) (entity, error) does not mutate state.
For an early implementation of the
fes
package, we went for a Java-like inheritance approach for the updating of event store models. Each one required 'extending' the fes.BaseEntity and implementing the fes.Entity interface to support copying and state mutation.Since our Golang expertise has grown, and we have more experience with using event sourcing, this clone-mutate approach has turned out not to be the best idea. It complicates the code a lot, with few (if any) benefits.
To simplify the codebase, we should probably remove the current clone-mutate approach, use
cache.GetAggregate
for everything, and ensure thatApplyEvent(entity, events) (entity, error)
does not mutate state.