I\'ve been using UML for a while and I\'ve read few articles, books, forums about it but I still don\'t REALLY understand when two classes should be connected with association l
First of all an arrow represents navigability of the association. Single arrow means unidirectional relation, in this case only the source class knows about the target class. Arrow on both ends means bidirectional relation, where both classes know about each other. If no arrows are present the association can be either bidirectional by default or suppressed for the sake of readability. In practice you should draw arrows only when you want to emphasize the direction of the association.
When it comes to your second question, only the first case describes an (unidirectional) association between MainClass
and OtherClass
. Neither arguments nor return values imply association in the UML sense (although both imply dependency). In the last example there is an association between MainClass
and Something
class through the something
attribute. As a rule of thumb you should look for associations in attributes.
Please note that there is a concept of dependency
in UML and it is represented by a dashed line.
Pozdrowienia!