JD.
JD.

Reputation: 15551

DDDSample, should there be a repository.save in controller?

I am looking at the DDD Sample for .net provided by DDD sample at Codeplex and trying to understand how the various layers work with DDD.

With the sample, I can see when a new Cargo is created the aggregate root Cargo is stored via the repository in the BookingService.BookNewCargo() call. However, when I assign a new route or change a destination (AssignCargoToRoute() or ChangeDestination() calls in BookingService) I expected a CargoRepository.Store() to be called as well.

Code sample using Nhibernate which I have not used before.

What am I missing?

In other words, how is the aggregate getting persisted if Store() is not called?

JD

Upvotes: 0

Views: 256

Answers (2)

Paul T Davies
Paul T Davies

Reputation: 2573

Here is a sample application I wrote:

http://clientdatasystem.codeplex.com/SourceControl/list/changesets

And here is my accompanying blog:

http://lucidcoding.blogspot.com/2011/10/enterprise-software-architecture-how-to.html

As you may note in my blog, I don't describe it as DDD, but as following the Domain Model pattern. It is simpler than the Cargo application, and may suit your needs better. I follow the pattern of create and save, and also update and and save that you were expecting. I'm not saying my sample is better than Eric Evans's (I wouldn't dare!) but the Cargo Application is not completely a basic, stripped down version.

Upvotes: 0

flq
flq

Reputation: 22859

hm, i've seen a number of switch statements in the domain, seems like there are a few core terms missing in the domain. at first glance a number of areas seem to have quite a bit of ceremony, but hey, it's just a first impression.

udi dahan's domain events pattern has been used here, there is an event handler "cargo has been assigned to route" which seems to store the object in question. watch out for usages of the domainevents class in combination with the proper event class, i hope that will tell you what triggers the store.

Upvotes: 1

Related Questions