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
Edit: Rewrote answer following discussion in comments (thanks to Chimp for pointing out what I overlooked in Example 4)
Example 1: OtherClass is an attribute of MainClass, and thus is modelled as an association.
Examples 2 and 3: OtherClass is referenced within the class definition, although not stored within an attribute, hence is a dependency.
Example 4: The Something class is an attribute, and therefore an association, while the referenced OtherClass, which is not stored in an attribute, and so it is dependency.
Within UML, dependencies and associations are both types of Relationship and are not strictly related (except through a common supertype), although in my opinion an association implies a dependency.
Associations are indicated by a line between the 2 classes with multiplicities at each end. Navigability is indicated by arrows showing which class is aware of which (E.g. Class A ___> Class B means A is aware of B, but not the other way around) navigability in both directions is shown by arrows at both ends. Where there is no arrows it usually safer to make no assumptions about navigability unless stated elsewhere.
Dependencies are indicated by a dashed line with an arrow from the dependant class (client) to the class being depended on (supplier) (E.g. A ----> B means A is dependant on B). Dependencies show that a class is referenced at some point, and as such the client is dependent on operations provided by the supplier, but it doesn't indicate how it is referenced (unlike an association that suggests a reference stored in an attribute).