Closed Jaspertzx closed 6 months ago
I think number 2 will be subjected to the same reasoning as number 1 though? A brochure doesnt make sesne without the Handout it is a part of?
In this kind of exam question, if composition is expected, there will be additional hints to indicate a whole-part relationship (which is the definitive requirement for composition). For examples, phrases such as composed of
, part of
.
Related comment https://github.com/nus-cs2103-AY2324S2/forum/issues/915#issuecomment-2078669479
Thanks Prof, just one last quick question, if it is in a whole-part relationship, can the dependency line from Section to Handout be removed? Section has a static method with a Handout Object, meaning that it would be depend on the Handout Class. Does this composition relationship capture this dependency as well?
Included a photo just in case it's too confusing.
Section has a static method with a Handout Object, meaning that it would be depend on the Handout Class. Does this composition relationship capture this dependency as well?
@Jaspertzx
classDiagram
Foo *--> Bar
classDiagram
Foo --> Bar
In both cases above, there is no point showing Foo ------> Bar
dependency, as there is already an association in that direction. So, the diagram below is incorrect. Furthermore, this is nothing to do with composition. It's dictated by the navigability of the association, irrespective of whether it is also a composition or not.
classDiagram
Foo --> Bar
Bar <.. Foo
But it doesn't also imply a dependency in the reverse direction Foo <------ Bar
So, if there is a dependency in the reverse direction (due to some other factors), you need to show it separately, like this:
classDiagram
Foo --> Bar
Bar ..> Foo
Understood, thank you so much Prof!
When do we know to use the composition symbol? My intuition here would be:
Is my intuition correct? Or is there something I'm missing here. Thank you in advance!