I the following two classes:
class a {
void foo(){
b object= new b();
object.baar();
}
}
class b {
void baar(){
}
}
How to express class a using class b with Class Diagram (which arrow to use)?
You would need to put a dashed dependency line, which may be directional or not.
b makes use of class a, the dependency line should be bidirectional (or directionless)b does not make use of class a (except possibly through callbacks not tied directly to a) make the dashed line directional from a to b.
Whenever one class has a reference/uses another, it is said to have a dependency on it. In your example, class a uses class b. Therefore class a has a dependency on class b. For that, you can use the UML dashed line with open arrow as described here.
This is a very general relationship.
One class depends on another if the independent class is a parameter variable or local variable of a method of the dependent class.
If your class a had an instance variable, you would use the association link instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With