event sourcing - Passing around complete objects when applying CQRS/ES -
event sourcing - Passing around complete objects when applying CQRS/ES -
through research i've done implementing cqrs/es (i'm aware aren't tied each other), haven't yet seen total object passed command.
for example, why shouldn't take in parameters bug in bug-tracking api so:
[httppost] public iactionresult createbug([frombody] bug bug) { if (!modelstate.isvalid) { homecoming new httpstatuscoderesult(400); } else { commandhandler.handle(new openbug(bug)); homecoming new httpstatuscoderesult(201); } }
where openbug command:
public class openbug : icommand { public guid id { get; set; } public models.bug newbug { get; set; } public openbug(models.bug bug) { id = guid.newguid(); newbug = bug; //create bugopened event here (and add together event sequence?) } }
from i've seen, it's handled more this:
commandhandler.handle(new openbug(bug.description, bug.fixed));
and constructed elsewhere.
is there specific reason this? surely, i'm missing here or doing incorrectly.
assuming bug
complex class various properties or fields, each of these custom types other properties , fields, etc., you'd putting quite burden on client supply entire object graph open bug.
you can apply postel's law here: if need open bug illustration bug id, else puts unwarranted constraint on client. you'd making api harder use. doesn't fit cqrs ideal of task-based uis.
in a white paper can hard find on internet, greg young explains problem of transmitting big dtos , forth between application tiers.
cqrs event-sourcing
Comments
Post a Comment