How to model dependency injection in UML ?

Posted by hjo1620 on Stack Overflow See other posts from Stack Overflow or by hjo1620
Published on 2010-05-07T10:17:44Z Indexed on 2010/05/07 10:38 UTC
Read the original article Hit count: 252

Filed under:
|

I have a Contract class. The contract is valid 1 Jan 2010 - 31 Dec 2010.

It can be in state Active or Passive, depending on which date I ask the instance for it's state. ex. if I ask 4 July 2010, it's in state Active, but if I ask 1 Jan 2011, it's in state Passive.

Instances are created using constructor dependency injection, i.e. they are either Active or Passive already when created, null is not allowed as a parameter for the internal state member.

One initial/created vertex is drawn in UML. I have two arrows, leading out from the initial vertex, one leading to state Active and the other to state Passive.

Is this a correct representation of dependency injection in UML ?

This is related to http://stackoverflow.com/questions/2779922/how-model-statemachine-when-state-is-dependent-on-a-function which initiated the question on how to model DI in general, in UML.

© Stack Overflow or respective owner

Related posts about uml

Related posts about dependency-injection