crazy
crazy

Reputation: 57

How to model dependencies over multiple levels in UML?

I want to make an UML diagram and show the dependencies between three classes: TransparentOverlayCamera, ViewCameraView and SubpartCameraPreview.

enter image description here

TransparentOverlayCamera has access to ViewCameraView and the other way around. So I used a bidirectional association.

ViewCameraView has access to SubpartCameraPreview but not the other way around. So I used a unidirectional association.

But ViewCameraView also passes an instance of TransparentOverlayCamera to SubpartCameraView, so that it has access to TransparentOverlayCamera.

How do I model this last association in UML correctly?

Upvotes: 1

Views: 375

Answers (2)

Vladimir
Vladimir

Reputation: 2129

There is not necessary to use dependency relationship in your model. If you need to define structural relationship between classes , association is enough.

Be careful, association has no direction. Arrows at the association end represents navigability. Navigability defines that, instance at the association end is unambiguously identifiable. Association does not define communication as well.

If something is passed to instance, it is not a structural model but behavioral. You probably mean passing argument to operation. You need to define operation with arguments of specific type.

From you example: TransparentOverlayCamera will be set as argument type of operation defined on SubpartCameraView class.

Upvotes: 0

xmojmr
xmojmr

Reputation: 8145

  1. You can draw the usage dependency link from SubpartCameraView to TransparentOverlayCamera

  2. If you want to avoid circles and keep your architecture layered then cross-layer dependencies are often modeled through <<interface>> as in this example: http://www.uml-diagrams.org/design-pattern-abstract-factory-uml-class-diagram-example.html

  3. See also: http://www.uml-diagrams.org/component-diagrams.html#provided-interface

Upvotes: 1

Related Questions