solnic/dm-session — comment on commit cbebe60daf08f9b658b9c5f65c4ed76f56a943d2
File:  line 0
By dkubb:

@solnic one thing you'll see in DM1 is that I provide "state" objects that know how to commit/rollback. They were an extraction from the DM UoW work, but I never got the rest of the UoW working.

I think that might not be such a bad thing to consider; a state machine is created for each object added to the session, the state machine is responsible for handling state transitions of the object when the session is committed or rolled back.

For example there could be a state for representing a "dirty" object. It would have a commit and rollback method. When the session is asked to commit, the "dirty state machine" would know how to persist the object and return a new state machine for representing the "clean" state. Likewise, if the session was asked to rollback, the "dirty sm" would reset the object state, and return a new clean sm.