On Tue, Oct 6, 2009 at 11:04 AM, Rickard Öberg <[email protected]> wrote:
> Hi,
>
> I tried using the Lifecycle interface to initialize Entity state,
> specifically to set a "created on" Date property, but I realized that
> Lifecycle is really of limited value in a system which uses EventSourcing,
> as we do.
>
> The reason is that the entity itself is being created as a consequence of an
> event, which can either happen at the point that the command to the domain
> model is being processed, or much later during an event replay. In either
> case the resulting domain model state much be exactly the same, and if
> you're doing things in Lifecycle that is going to be tricky.
>
> In my case I was setting a Date property to "new Date()". During command
> processing that would be fine, but during event replay that is entirely
> wrong, since the date must be what it was when the event to create the
> entity was generated.
>
> So, for this reason the Lifecycle interface, although potentially very
> practical, is of limited use in an EventSourcing setup.

Yes, because you have your "lifecycle" baked into the Event themselves
(projectCreated) and can therefor put such initialization in
listeners/concerns of the event. That doesn't exclude practical usages
elsewhere.


Cheers
-- 
Niclas Hedhman, Software Developer
http://www.qi4j.org - New Energy for Java

I  live here; http://tinyurl.com/2qq9er
I  work here; http://tinyurl.com/2ymelc
I relax here; http://tinyurl.com/2cgsug

_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev

Reply via email to