0

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?

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
A.Nassar
  • 27
  • 5
  • 1
    @bruno I agree. I simply was asking what is the best representation for this case. I hope the one who marked this question reconsiders! – A.Nassar Jun 17 '20 at 16:43

1 Answers1

2

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
bruno
  • 32,421
  • 7
  • 25
  • 37