Closed wendy0107 closed 1 year ago
I think we can show A --> B --> A in an object diagram. Here is one example:
Item
-> Box
and Box
-> Item
, forming a loop.
See here for some details (under the Combine
header).
@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.
@damithc In the context of an exam question! I don't have an exact question however
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!
@Zxun2 Okay thank you!
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.
@damithc Okay got it thank you so much!
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?