UML association understanding problem

前端 未结 4 1822
一向
一向 2021-02-04 15:24

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

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-02-04 16:00

    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.

提交回复
热议问题