nus-cs2103-AY2223S2 / forum

12 stars 0 forks source link

Navigability between Class and Object diagrams #433

Closed wendy0107 closed 1 year ago

wendy0107 commented 1 year ago

Since a class diagram showing (A --> B) or (B-->A) can be represented as (A---B) in an object diagram as its considered omitting navigabilities. Is the converse the same?

For instance if a class diagram has an association between A and B (A----B). Will an object diagram showing (A --> B) or (B---> A) be an acceptable representation?

BoAi01 commented 1 year ago

I think we can show A --> B --> A in an object diagram. Here is one example: image Item -> Box and Box -> Item, forming a loop.

See here for some details (under the Combine header).

damithc commented 1 year ago

@BoAi01 I think @wendy0107's question is, if it is OK for class diagram to show navigability but the object diagram to omit it, is it also OK for the object diagram to show navigability but for the class diagram to omit it.

@wendy0107 Are you asking this in general, or in the context of an exam question in which you need to decide which object diagrams are compliant with the given class diagram (or vice versa)? If the latter, it'll help to cite the exact question, for context.

wendy0107 commented 1 year ago

@damithc In the context of an exam question! I don't have an exact question however

Zxun2 commented 1 year ago

Personally, I think it is fine for the object diagram to show navigability while the class diagram omits it, or vice versa. Both class and object diagrams serve different purposes, and it's not always necessary to show navigability in both diagrams, as the information provided in one diagram may not be relevant or important for the other diagram. It should be included if showing navigability is relevant and adds value to the diagram. If not, it can be omitted!

wendy0107 commented 1 year ago

@Zxun2 Okay thank you!

damithc commented 1 year ago

I agree with @Zxun2's reply. Provided the navigabilities are correct, it is fine to omit them from class and/or object diagrams if the said navigability is not relevant to the purpose of the diagram.

That said, if you are drawing an object diagram purely based on a class diagram, and the class diagram does not show navigabilities, you will not know which direction the navigabilities really are, and will have to omit them from the object diagram as well.

wendy0107 commented 1 year ago

@damithc Okay got it thank you so much!