I am working on an application where client and server share an object model, and the object graphs can become rather big.
To save an object from client to server, i
I am planning my first N-tier architecture and came across this question just as I was about to post a similar one. All the sample code I’ve seen so far passes the entire object graph over the wire every time, without regard for what changes have actually been made. I've been considering to instead take the approach described above. Although, it appears to be the road less traveled.
I like the idea of passing back just the deltas for each modified property. For collection properties, this would be what’s been both added and removed. For a single-valued property, it could be just the new value. I could implement this in a general way such that the accumulation of these deltas would be transparent for all domain objects. And the deltas would be sent across the wire in a general form, without using DTO classes specific to my domain model.
This made me wonder if I couldn't take the idea further by also using the same general-purpose delta data structure for communication in the direction of server to client. After all, you could have a delta that basically populates an empty object. Then I could altogether eliminate the hard-coded DTO classes. I Googled "generic DTOs" (without quotes) and found this and this. Looks like others have already applied the idea in practice.