Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Class Diagram: Default value for unmentioned multiplicity #196

Open
qweiping31415 opened this issue Nov 28, 2019 · 6 comments
Open

Class Diagram: Default value for unmentioned multiplicity #196

qweiping31415 opened this issue Nov 28, 2019 · 6 comments

Comments

@qweiping31415
Copy link

qweiping31415 commented Nov 28, 2019

I have a question regarding unmentioned multiplicities in class diagrams. From the sample paper, I assumed that unmentioned multiplicities meant that it holds a default value to 1, but I’m not sure whether that assumption affects my answer for the following questions. Could I clarify whether my assumption is true in the module and whether it affects the explanation of my answers?

First MCQ

A13. A Lid must be associated to a Container but it is optional for a Container to have a Lid.
The stated answer is (B). This is because the association label could be a Lid#close(Container) method, hence this is a dependency from Lid to Container instead of an association. This possibility also counters the given code scenario in A17.

Picture2

@damithc
Copy link
Collaborator

damithc commented Nov 28, 2019

must be associated means there should be a 1 multiplicity in the diagram, which the diagram doesn't have. Hence, B.
Unmentioned does not default to 1.

@qweiping31415
Copy link
Author

qweiping31415 commented Nov 28, 2019

Does unmentioned default to 0..1? I missed out the possibility of null value.

If not, what does it default to, if any?

@damithc
Copy link
Collaborator

damithc commented Nov 28, 2019

It does not default to anything. It is unknown.

@jxofficial
Copy link

jxofficial commented Nov 28, 2019

Am I correct in saying this:

If the arrow is like this Container → Lid it means that only Container knows about Lid. ie Container is associated with Lid. But Lid is NOT associated with container
class Container { Lid lid; }

But Lid definitely does not know about Container right? ie Lid is NOT associated with Container Because if it does, then it would be: Container — Lid without the arrow head (navigability)

@damithc
Copy link
Collaborator

damithc commented Nov 28, 2019

Am I correct in saying this:

If the arrow is like this Container → Lid it means that only Container knows about Lid. ie Container is associated with Lid. But Lid is NOT associated with container
class Container { Lid lid; }

But Lid definitely does not know about Container right? ie Lid is NOT associated with Container Because if it does, then it would be: Container — Lid without the arrow head (navigability)

Don't confuse navigability with association. If A is associated with B, B is automatically associated with A, irrespective of the navigability.

  • A → B
    • The A class is associated with the B class
    • The B class is associated with the A class
    • An A object has a reference to the B object it is associated with
    • A B object does not have a reference to the A object it is associated with

@jxofficial
Copy link

Thank you, that clears things up!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants