Closed domlimm closed 2 years ago
Door is the one that is not compliant. Since there must be one Door.
In that case, should Object diagram capture all objects created from a class diagram?
I selected the above options as well because I thought not all objects need to be captured in an object diagram.
Hint: If you wanted to say "Every Table
object must be associated with exactly one Door
object (i.e., a Table
object cannot exist without an accompanying Door
object)", how would you show that in the class diagram?
In that case, should Object diagram capture all objects created from a class diagram?
Not necessarily. Depends on the multiplicities.
Door is the one that is not compliant. Since there must be one Door.
Hey @ngjunkang! Could you please elaborate further? I don't see any Door object :')
Would both options that have Door
work? Because we can't really tell the multiplicity. Unless I'm missing or not seeing something...
Door is the one that is not compliant. Since there must be one Door.
Hey @ngjunkang! Could you please elaborate further? I don't see any Door object :')
Would both options that have
Door
work? Because we can't really tell the multiplicity. Unless I'm missing or not seeing something...
hi @domlimm!
Not sure if this was what @ngjunkang meant, but I think it is because the 3rd option indicates that there must always be 1 door regardless of the number of Table objects. However, based on the question given, there is no association given between a door object and table object. So third option definitely cannot be true.
In contrast, second option is compliant because of the *
- Meaning there could be 0 table objects, and it still complies with the question.
Or another way to think about it as Prof mentioned would be that for the given class diagram in option C, would the given object diagram in the question still be correct?
@domlimm Look at the third option, the class diagram is trying to show that every Table
class must be associated to any number of Chair
and exactly one Door
. However, the object diagram only shows the association between a Chair
and Table
object. For the third option to be correct, the object diagram needs to be like this: :Chair -- :Table -- :Door.
Hey @domlimm! For the second option, since it says that each Table can be associated with 0 to n Doors and the actual object diagram has 0 Doors, it is right.
But for the third option, since each Table must have exactly one door (compulsory association), and the object diagram has 0 Doors, it is incorrect.
HELLO @lzan98 @ngjunkang @ckcherry23! Alright I understand guys. Thank you so much! WHOOPS YEAH MISSED THAT PART ðŸ˜
Will just close this now! Thanks again!
but I think it is because the 3rd option indicates that there must always be 1 door regardless of the number of Table objects.
@lzan98 this interpretation is not correct. When interpreting the multiplicity of one end, the other end is considered 'for each object of X' (not as "regardless of the number of X objects" as you have suggested). Consider the following multiplicity:
When interpreting it, we don't care about the *
at the other end. That end will be read as "For each Table
object ...". So, the full interpretation is "For each Table
object, there should be exactly one Door
object".
Similarly, the other end is interpreted as "For each Door
object, there can be any number (i.e., *
) of Table
objects connected to it".
All these object diagrams are compliant with the above class diagram: Diagram 1:
[_:Table_]---------[_:Door_]
Diagram 2:
[_:Table_]---------[_:Door_]
[_:Table_]---------[_:Door_]
Diagram 3 (a Door
can exist without a Table
):
[_:Door_]
Diagram 4:
[_:Table_]---------[_:Door_]-----------[_:Table_]
But these are not compliant:
Diagram 5 (one Table
cannot have two Door
objects):
[_:Door_]---------[_:Table_]---------[_:Door_]
Diagram 6 (a Table
cannot exist without a Door
):
[_:Table_]
but I think it is because the 3rd option indicates that there must always be 1 door regardless of the number of Table objects.
@lzan98 this interpretation is not correct. When interpreting the multiplicity of one end, the other end is considered 'for each object of X' (not as "regardless of the number of X objects" as you have suggested). Consider the following multiplicity:
When interpreting it, we don't care about the
*
at the other end. That end will be read as "For eachTable
object ...". So, the full interpretation is "For eachTable
object, there should be exactly oneDoor
object". Similarly, the other end is interpreted as "For eachDoor
object, there can be any number (i.e.,*
) ofTable
objects connected to it".All these object diagrams are compliant with the above class diagram: Diagram 1:
[_:Table_]---------[_:Door_]
Diagram 2:
[_:Table_]---------[_:Door_] [_:Table_]---------[_:Door_]
Diagram 3 (a
Door
can exist without aTable
):[_:Door_]
Diagram 4:
[_:Table_]---------[_:Door_]-----------[_:Table_]
But these are not compliant: Diagram 5 (one
Table
cannot have twoDoor
objects):[_:Door_]---------[_:Table_]---------[_:Door_]
Diagram 6 (a
Table
cannot exist without aDoor
):[_:Table_]
Thank you for the detailed clarification prof!
Hello, could the wrongly selected option be correct too? As
*
multiplicity is 0..*.Though, it shouldn't be the answer because in this object diagram shows it's just 1 to 1.
Thank you!