How to model dependency injection in UML?

I have a contract class. The contract is valid from January 1, 2010 - December 31, 2010.

It can be in Active or Passive state, depending on what date I request from the instance for it. ex. if I ask on July 4, 2010, it is in Active state, but if I ask on January 1, 2011, it is in Passive state.

Instances are created using embedding constructor dependencies, that is, they are either active or passive at creation time, null is not allowed as a parameter for the internal member of the state.

One start / created vertex is drawn in the state diagram of the UML machine. I have two arrows leading from the starting vertex, one of which leads to an Active state, and the other to a passive state.

Is this the correct representation of dependency injection in UML?

The question specifically relates to statemachine diagrams, where the first state after the initial state / vertex is defined outside the diagram.

The Jude / Ashtah tool allows such constructions, i.e. pulling a few lines from the inital vertices of the diagram, which leads me to think that this is the correct graphical UML syntax.

This is due to How is the statemachine model when the state is function dependent? who initiated the question of how to model DI in general, in UML.

+4
source share
3 answers

you can solve some of the states, as I suggested in your other question, and DI can be shown using the dependency in the class diagram.

+1
source

I would say no. The question to ask is: Is the state of the machine / class behavior different from the active and passive versions of your class?

If so, use two separate state machine diagrams below the class object: one for the passive and one for the active.

An activity diagram can be used to show that a choice has been made (using a join) before creating the class.

If both instances behave the same and therefore go through the same states, then simply place the label in the initial transition to the first state to show this and, possibly, the entry procedure in the first state to show it.

0
source

Including dependencies is just an implementation detail (even if it is very important). So, on the question of how to model dependency injection in UML, you can model DI as an association, aggregation, or composition, depending on what you want to express using these classes.

0
source

Source: https://habr.com/ru/post/1309092/


All Articles