0
votes

I'm currently in a situation where I'm replacing the domain layer of an application but must retain the existing MVVM UI. We definitely want an event store, but I'm struggling with some aspects of our current CQRS implementation.

We have some complex aggregates that contain multiple entity collections and key/value pair dynamic attributes. Our existing UI has one large edit screen for this aggregate and I'm not sure how to structure the command(s) for the update.

Possible solutions: 1) Simply fetch the aggregate in the ViewModel, perform the updates against the domain model, and ship it with the command (var command = new SaveAggregateCommand(myAggregate);). This feels wrong as the internal events would not be retained if shipping this across a serialized boundary (without custom serialization).

2) Create one complex command object that contains a list up updated attributes and separate lists of added, updated and removed child entities of each collection type. This would be the easiest for the command handler to work with but feels very sloppy.

3) Create many commands that basically mirror the domain model's events that get captured (there would be up to 38 in my scenario). The view model would then have to keep a list of uncommitted commands that get submitted when the save button is pressed by the user. Like #2, this also feels hacky.

Due to the (necessary) complexity of this aggregate, none of these solutions feel right. I would live some guidance on this one.

1
That sounds like a super sized aggregate. Can you tell us more about the AR? Why did you choose ES? Capturing intent in this scenario is a PITA, can you change the UI?JefClaes
Changing the UI must come later. This was a business decision. Everything in the AR needs to be there. It really can't be broken up any more.agartee
You can go with one big command, and reverse engineer intent at the application layer.JefClaes
So, there are more commands than the one to do the CRUD update things. Those would be separate. The issue I have is just that I need an event stream tracking the modifications on one large set of data that is saved all at once in the legacy UI.agartee
After reviewing and building out the various commands, things weren't as big and complex as I thought there were going to be. My biggest command only has 13 properties. Appreciate the input!agartee

1 Answers

0
votes

So, the answer is: I was doing it wrong. The commands were broken up into more manageable and specific pieces, and the peasants rejoiced.