UML association vs. composition and detail level

前端 未结 4 1544
北荒
北荒 2020-12-04 20:21

Actually, make that a couple of amateur UML questions! When creating a UML diagram to model some domain concepts and you come across a domain concept that \"holds\" some inf

4条回答
  •  庸人自扰
    2020-12-04 20:49

    For your first example, the first diagram, with composition, is correct. Your second option, referring to flightID as an int, could work but it's incomplete: that int by itself doesn't give you a way to access the Flight object. The Flight class doesn't magically store a list of flight objects that you can retrieve by number, so that second option would need a third class somewhere to store all the Flight objects.

    For your second question, at the high level it really depends on personal preference (or your professor's personal preference!). Just try to use your best judgement.

提交回复
热议问题