I'm having a bit of a hard time figuring this out. I have a model (which you can see in the image below) this model can be changed (it won't happen often, but it can). When it changes I do not get the changes I get the ENTIRE data set, I get this set in the following order (don't know if it's relevant): First i get all the labels, then i get all the stations, then the filters, then the types and finally the messages.

Updating the properties of these classes is no problem, I'm getting stuck when i need to update the hierarchy, since they are all connected with one another.

I have made an overly complicated web of update methods for all the models where they would notify those who have a record of them that they are being removed but the further i got with this the more i got lost in the code I was writing. So i decided to take a step back and think of a more simplified way. Unfortunatly I do not know of a easy-to-read way to update this model.

The hard tihng is with the active messages and procedures. If a label (trigger of the message and enabled of the filter) have become active the message needs to become an ActiveMessage. This active message needs to be handeled according to a procedure. when the message becomes active I create a stateful procedure which keeps track of which steps have been completed.

When i updated the model i need to keep in mind i cannot delete old active messages which still need to be handled and I need to check if because of the changes new messages have been activated. A message can also be deactivated if the enabled label of the filter has become inactive or the reset label of the messages has become active. So with all these dependencies I'm at a loss.

Can someone help me figure out a proper way to update this?

The model: enter image description here

  • You start with some instances, and later you get more instances, some of which are duplicates from before?
    – Erik Eidt
    Nov 18, 2016 at 17:31
  • @ErikEidt well yes they are sort of duplicates but they have a state and some extra information.
    – Vincent
    Nov 21, 2016 at 7:27

2 Answers 2



  • Your model has navigational properties (e.g. Label -> Message, StationFilter <-> Station); try to eliminate one side of the relationship to lessen the mental overhead and the need for temporarily inconsistent entities; this makes the answer to "which entity owns the relationship" come naturally.
  • Decide whether you want your objects to change their state (OOP) or whether to use a transaction script to orchestrate the changes to them from some "controller" or "command" class.
  • Whichever you choose, always ensure your object invariants hold. Each use-case you're describing should be modeled as a single execution over an object graph that is consistent before the execution starts and after the execution starts.
  • The runtime – transactional/RDBMS/event sourcing/distributed system matters — e.g. I don't see any Id properties; does that mean they all have it, or none of them have it? Try to make as many things as possible value objects without Ids referenced from outside the graph, while if this is a table-mapped object model, keeping surrogate keys in each entity managed by another.
  1. Change your model so it is easy to update: remove the invariant checks and restrictions when updating the model.
  2. If a model element must change its class type when updating, eliminate that change: use a single class, and if you need to differentiate behavior or data storage in instances, use child objects that can be swapped out without changing references to the parent object.
  3. Move the invariant checks to a recursive, top-down invariant checking method. This method may need to make corrections, but you control the order of operations entirely.
  4. First update the model, then run the invariant checks.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.