0

I'm learning UML right now and ran into the following question.

public class Alpha{
    Beta b;

    void function(Beta c){
        c.doSomething();
    }
}

I'm not quite sure on what arrow I should be using. It has an Association because of "Beta b". But it also has a Dependency because it uses Beta c in a function. Beta b and c are completely independent from each other. Can i use both arrows at the same time or is one of them stronger than the other?

V.S.
  • 3
  • 1

2 Answers2

1

There is no definite answer. According to the Unified Modeling Language Reference Manual:

Note that association and generalization fit within the general definition of dependency, but they have their own model representation and notation and are not usually considered to be dependencies...

which means that if the use of Beta through c can benefit from being modeled as a dependency, it might make sense to do so, in some more complex situations (not illustrated by the code, being a mock-up).

See also:

SDJ
  • 4,083
  • 1
  • 17
  • 35
0

You talk about 'arrows', but an association does not always have an arrowhead. In this answer, I will compare an assocation A -> B and a dependency A -> B both with an arrowhead pointing from A to B.

I would say that the association implies a dependency, so if you draw the association, you can leave out the dependency. The reason is that because of the association, A depends on B, because without B, A could not have the association with B.

However, from the UML 2.5.1 specification, this is not obvious. The specification does not consider association a special kind of dependency.

www.admiraalit.nl
  • 5,768
  • 1
  • 17
  • 32