What object is responsilbe for an action? A Design Question.  
Author Message
slabanum





PostPosted: Architecture General, What object is responsilbe for an action? A Design Question. Top

Hi,

I have a project where I have a ValidationCase object which contains ExceptionEntries collection of ExceptionEntry. I start off with a ValiationCase being populated already and presented on a GUI and the client user works on it:

  1. The client user does some manual checking on the ExceptionEntries, decides that they are okay and flags the ExceptionEntries as a Valid state.
  2. The client user then does a save on the ValiationCase (ValidationCase.Save()). This call goes to the db and does the persitence mechanism. It is determined that all ExceptionEntries at this point are Valid so the ValidationCase is flagged as a "Valid" state.
  3. Due to the ValidationCase being flagged into a Valid state, there is a side effect where another process is kicked-off, like when the ValidationCase's State is Valid then run the Batch Calculation Process.

My question is since the saving of the ValidationCase to a Valid State has a side-effect of running another process, should this behavior of determining when another process is kicked-off the responsibility of the ValidationCase

I am kind of feeling that this is the ValidationCase's responsibility since it knows it's own state. But then again, this kicking-off of a new process is something like a workflow that can be orchestrated outside the ValidationCase, hence another object should be the one responsible for this workflow processing.

If it is indeed another objects responsibility and not the ValidationCase, how then can I tie a client user clicking a save on the ValidationCase to this workflow process manager. Any patterns you can suggest

Please provide some thoughts.

Thank you.



Architecture4  
 
 
Arnon Rotem Gal Oz





PostPosted: Architecture General, What object is responsilbe for an action? A Design Question. Top

I am not sure I understand all you requirments so I might be wrong - but the way I understand what your saying I would probably have the exceptionCase publish its state (e.g. raise an event when it is updated) and have any interested object react to that change (e.g. initiating the side effect)

Also the fact you use the term "side effect" makes it sound like it should not be part of the transaction that saves the change - which strengthens the point I made above

Arnon