nus-cs2103-AY2122S2 / forum

14 stars 1 forks source link

Question regarding showing composition #301

Open Punpun1643 opened 2 years ago

Punpun1643 commented 2 years ago

I'm wondering if showing composition in the class diagram with an arrowhead is considered correct and is the same thing as showing the one without an arrowhead?

For example, in this diagram in the sample answer from the Practice Exam, I initially drew composition with an arrowhead because I thought that an Activity object also has reference to its sub-activities.

A458C7F4-F746-4508-A55E-F3426D62CCEE

Another example is in the week 8 tutorial where the composition is shown with an arrowhead: 3C55608C-96A3-4DE6-A804-5EDB57311BC9_4_5005_c

However, in the module website composition should only be shown like this: 095E3F01-9489-449B-AC09-0F02875AC008_4_5005_c

I'm also a little conflicted because I think showing composition already implies that Whole has a reference to Part?

damithc commented 2 years ago

@Punpun1643 Partial answer (leaving the rest for discussion): composition (i.e., the diamond) and navigability (i.e., the arrowhead) are two independent things.

jamesyeap commented 2 years ago

I think its also possible to have the sub-activities keep a reference to the parent-activity? So because it is not specified as to who would be keeping the reference, the navigability is unknown, and it would be safer to just leave out the arrowhead (in my opinion).