Thanks Fabio and Andy,

Would love to hear more about your ideas Fabio - sponsorship for a
project like this may be an option for us dependening on where we take
our application. Is the best thing to email privately if this is a
possibility?

Andy - thanks for the clarification around DDDD. I have browsed some
of Greg's posts before but will go and re-read and have a think about
how those patterns might be applied to our domain. Maybe this
discussion should belong on the Alt.NET list instead...

Will


On May 16, 4:35 am, Andy Hitchman <[email protected]> wrote:
> Perhaps Event Sourcing <http://martinfowler.com/eaaDev/EventSourcing.html> 
> (http://martinfowler.com/eaaDev/EventSourcing.html) is a better pattern for
> you?
>
> In a nutshell, instead of storing the state of objects after changes, store
> the events (messages) that cause the changes. You can then replay events to
> rehydrate an object at any previous point in time.
>
> Not sure it is really as easy as this explanation sounds. It needs careful
> consideration of side effects (your Person--Address association being a
> prime example). It probably works best if an aggregate root is responsible
> for all message handling, rather than entities individually.
>
> Have been considering something like this for a while (but haven't got a
> real reason to try it). Greg Young has posted quite a
> bit<http://codebetter.com/blogs/gregyoung/archive/tags/DDDD/default.aspx>about
> this style under the moniker 'DDDD'. My idea was to create a set of
> endpoints in MassTransit to do the heavy lifting (a bit like a Saga on
> steriods).
>
> On Thu, May 14, 2009 at 1:28 AM, Will Holley <[email protected]> wrote:
>
> > We are currently using NHibernate to store historical versions of
> > entities. The schema we currently use has 2 tables for each entity
> > (one containing only the most recent version and one containing all
> > the historical ones). A critical element to this mechanism is that we
> > need to be able to rehydrate an entity including its associated
> > entities for a specific version.
>
> > To illustrate using a trivial case with pseudo ActiveRecord, lets say
> > you have:
>
> > class Person
> > {
> >      [BelongsTo(Cascade = CascadeEnum.All)]
> >      Address PrimaryAddress { get; set; }
> > }
>
> > class Address
> > {
> >      [HasMany(Inverse = true)]
> >      IList<Person> Persons
>
> >      ....
> > }
>
> > When a Person is saved, historical entries for the Person and the
> > associated Address would be generated so that when you get the
> > historical Address you can see the Persons associated with it at that
> > revision. You then also have to create historical entries for all the
> > other Persons associated with the Address. Hopefully the sequence
> > below illustrates this:
>
> > 1. create first Person P1:
>
> >     A1 @1                                            History(A1)
> > @1
> >   /                generates ->                     /
> > P1 @1                                         History(P1) @1
>
> > 2. create second Person P2:
>
> >    A1 @1                                        History(A1)
> > @2
> >   /                generates ->                /               \
> > P2 @1                           History(P1) @2          History(P2) @1
>
> > 3. update first Person P1:
>
> >  A1 @1                                        History(A1) @3
> >  /               generates ->                 /                \
> > P1 @ 2                        History(P1) @3             History(P2)
> > @2
>
> > Despite the potential for an explosion in complexity, this approach is
> > working reasonably well for our specific use case. However, there are
> > significant problems in terms of a general solution. Specifically:
>
> > 1. You are generating a large amount of redundant data because you
> > create historical entries when the data hasn't changed (in this
> > example you would create an historical Address for each change to
> > Person even though the data in the Address entity has not changed).
>
> > 2. You have to fetch the complete graph of related entities in order
> > to do a trivial save / update - an obvious performance killer.
>
> > I have seen a lot of blog posts / group discussions about how people
> > deal with storing old revisions of one entity but I have not seen
> > anything discussing this problem of rehydrating complete historical
> > object graphs (maybe nobody else is crazy enough to do this?). I
> > cannot seem to find any precedent with other ORMs either (maybe I'm
> > missing the Google incantation?).
>
> > One idea we've had is that maybe it would be possible to version the
> > relationships between entities as well as the entities themselves.
> > This way we would not need to generate redundant rows when the data
> > itself hasn't changed (as in the example case).
>
> > Has anybody else done anything like this or have any thoughts on where
> > to research this problem?
>
> > Many thanks,
>
> > Will Holley
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to