c# - CQRS: Class Redundancy and passing DTO to Domain -


my cqrs application has complex domain objects. when created, properties of entity directly specified user,

createfoocommand has 15 properties.

foocreatedevent has 15 properties, because need entity properties on read-side.

as command parameters must dispatched domain object , foocreatedcommand should not passed domain,

there manual mapping createfoocommand domain.

as domain should create domain event,

that mapping domain foo properties foocreatedevent.

on read side, use dto represent structure of foo stored within read-model.

so event handler updating read-side introduces mapping event parameters dto.

to implement simple business case, have

  • two redundant classes
  • three mappings of same properties

i thought getting rid of command/event arguments , push dto object around, imply domain can receive or create dto , assign event.

sequence:

rest controller --command+dto--> command handler --dto--> domain --(event+dto)--> event handler 

any ideas making cqrs less implementation pain?

i see following options:

  1. create immutable dto class foodetails used both createfoocommand , foocreatedevent injecting in constructor; type hint aggregate method against foodetails; example new createfoocommand(new foodetails(prop1, prop2, ...))

  2. create immutable base class foodetails inherited both createfoocommand , foocreatedevent , type hint aggregate method against foodetails

  3. completely change style , use style promoted cqrs.nu in commands sent directly aggregates; aggregates have command methods fooaggregate::handle(createfoocommand command); use style lot.


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -