Search code examples
polymorphismumlclass-diagramstatic-polymorphism

Depicting static polymorphism in a UML class diagram


I have an object which is instantiated during compilation according to the build configuration. As far as the surrounding software considered, the object exposes the same interface. I would like to model the fact that the instantiation decision is taken during compilation (i.e. static polymorphism), as opposed to the usual dynamic polymorphism.

Is there a way to depict a static polymorphism in UML class diagram?

Here is more or less what I need:

enter image description here

Obviously, only one of the above type definitions will be instantiated at compilation.


Solution

  • Combining from @ChiragDesai and @user2004268 answers and linked question (Static polymorphism definition and implementation):

    1. Polymorphism type is an implementation detail and as such it doesn't have active role in design diagrams.
    2. Implementation details can be present in UML diagram but have a complementary and informal role. Stereotypes and notes can be used to clarify the intentions.