Is correct relationships of class diagram in UML?

前端 未结 2 1691
终归单人心
终归单人心 2020-12-22 07:10

The image shows the logistics of the Warehouse. Very very simplistic. What is its concept: There are documents: ReceivingWayBill, DispatchingWaybill

2条回答
  •  别那么骄傲
    2020-12-22 08:04

    It is so hard (maybe impossible) to correct your whole model with provided explanation. I give some improvements.

    1. You should put Multiplicity of you relationships. They are so important. In some relationship, you have 1 (ReplacementOrder , Warehouse) and some of your relatioships are maybe * (Item , ReceivingWayBill)

    2. You put Aggregation between your classes and we know that Aggregation is type of Association. You can put Associations too. You can find a lot of similar questions and answers that explain differences between Association and Aggregation (and Composition). see Question 1, Question 2 and Question 3. But I recommend this answer.

    I think, there is NOT a very significant difference between Aggregation and Association. See my example in this question.

    Robert C. Martin says (see here):

    Association represents the ability of one instance to send a message to another instance.

    Aggregation is the typical whole/part relationship. This is exactly the same as an association with the exception that instances cannot have cyclic aggregation relationships (i.e. a part cannot contain its whole).


    Therefor: some of your relationships are exactly an Aggregation. (relationship between Item and other classes). Your Counterparty has not good API definition. Your other relationships is about using Warehouse class. I think (just guess) the other classes only use Warehouse class services (public methods). In this case, they can be Associations. Otherwise, if they need an instance of Warehouse as a part, they are Aggregations.

提交回复
热议问题