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
An association represents two or more related properties.
In example 1, MainClass has a property of type OtherClass. If OtherClass has an explicit property of type MainClass then there will be a bidirectional association between the class; if OtherClass has an implicit property of type MainClass (i.e. there is no attribute, but the relationship can be derived by working in the other direction) then there will be a unidirectional association from MainClass to OtherClass.
In examples 2, 3 and 4, MainClass does not have any properties of type OtherClass. It is dependent on the OtherClass though, so there would be a dependency relationship from MainClass to OtherClass. In code this is represented by a using or #include.