A.Nassar
A.Nassar

Reputation: 27

UML Class Diagram Association vs Dependency

Let us say we have Class A, Class B, and Class C

Class A has an object of Class B: array = ArraList

Class A then passes this array to Class C

When drawing the class diagram which logic is the correct one:


Class A has an association with Class B and Class B, and Class C has a dependency with Class B

OR

Class A has an association with Class B, Class C has an association with Class A, and Class C has a dependency with Class B

Or are the both wrong? If so, what is the correct way of representing the following case in a class diagram?

Upvotes: 0

Views: 447

Answers (1)

bruno
bruno

Reputation: 32586

Class A has an object of Class B: array = ArraList

I suppose you mean Class A has the attribute 'array' being an 'ArrayList' of Class B, so ArrayList<B> array;

Class A has an association with Class B and Class B, ...

I suppose is Class A has an association with Class B, ...

Class A then passes this array to Class C

I suppose you mean this array is given in argument to an operation of Class C


Class A has an association with Class B, and Class C has a dependency with Class B

  • Class A has an association with Class B : yes
  • Class C has a dependency with Class B : yes if C knows it receives (through operation argument) instances of B and 'use' them

Class A has an association with Class B, Class C has an association with Class A, and Class C has a dependency with Class B

  • Class A has an association with Class B : yes
  • Class C has an association with Class A : there is nothing in your statement requiring that
  • Class C has a dependency with Class B : yes if C knows it receives (through operation argument) instances of B and 'use' them

Upvotes: 2

Related Questions