Domanda

I have the following diagram:

enter image description here

I want to model in it that the list of the StatusCommandManager has to be the same instance as the one in the StatusViewModel but I don't know how to model that with UML class diagrams.

Thanks.

EDIT:

For each instance of the StatusViewModel there will be an instance of the StatusCommandManager and both of them have to share the same list instance.

È stato utile?

Soluzione

So, would this model describe your situation (I prefer to show attributes of non-trivial types using associations)?

enter image description here

A couple of notes:

  • I added an association between StatusViewModel and StatusCommanderManager, based on your comment ("for each instance of the StatusViewModel there will be an instance of the StatusCommandManager"). Please let me know if "1 to 1" is ok, of you have "1 to n" instead
  • as instances of Lists are shared, you cannot use the composition (like in your example), but rather aggregation

If this understanding is correct, you have (at least) two options to add your restriction:

  1. Add somehow the restriction to the model, stating that the attribute StatusParameterViewModels of StatusViewModel must be equal to the same attribute of the linked StatusCommanderManager instance. There are several ways to include this statement in specification: A less formal way is just to add a note on the diagram and type it textually. A formal way would be to use OCL (please let me know if you need more info on this)
  2. Change slightly the model, as one of the aggregarions is reduntant in the first place. StatusViewModel and StatusCommanderManager are linked between each other and therefore it is enough that only one of them has a List. Another one can get it directly "asking" the first one.

The second option is definitelly recommended if there is no some strong reason (unknown from your description) not to apply it. The model would be simpler and clearer, no redundancy, the List is maintained centrally, whole logic is in the model (no external restrictions), etc.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top