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

Relationship between Associations and Dependancies #210

Open
anubh-v opened this issue Dec 2, 2018 · 10 comments
Open

Relationship between Associations and Dependancies #210

anubh-v opened this issue Dec 2, 2018 · 10 comments

Comments

@anubh-v
Copy link

anubh-v commented Dec 2, 2018

Hi all,
I wish to clarify the relationship between associations and dependancies.
I see the following 2 possibilities:

  1. Associations and dependancies are mutually exclusive.
  2. Associations imply dependancies. In other words, if there is an association between 2 objects, there is also a dependancy between them.

To illustrate, we can use this question from the practice exam.
image

The arrow from Container to Lid shows that there is an association between Container and Lid.
But is there also a dependancy between Container and Lid?

@anubh-v
Copy link
Author

anubh-v commented Dec 2, 2018

I came across this article that says that associations imply dependancies.

Associations also imply dependency, if there is an association between two classes, there is also a dependency. But I can't imagine a case where you would show that dependency as an extra line on the diagram. The association implies it, as does a generalization.

@anubh-v
Copy link
Author

anubh-v commented Dec 2, 2018

On the other hand, if we consider the first sentence of the following paragraph (from textbook) as a definition, then dependancies and associations are mutually exclusive.

image

@damithc
Copy link
Contributor

damithc commented Dec 2, 2018

  1. Associations and dependancies are mutually exclusive.
  2. Associations imply dependancies. In other words, if there is an association between 2 objects, there is also a dependancy between them.

It's the second one.

The two things are not mutually exclusive, but we show a dependency arrow only when there is no association arrow. If there is an association arrow, it is pointless to draw a dependency arrow as well; you can think of it as a solid arrow already contains a dashed arrow.

@pengnam
Copy link

pengnam commented Dec 4, 2018

@damithc In this diagram, is there an association from Lid to Container?
I understand that arrow head indicates the navigability of an association, but I am not sure if an association hence becomes 1-way instead of 2-way.

@pengnam
Copy link

pengnam commented Dec 4, 2018

image
In an association that is only navigable in one-direction, should we ever have a multiplicity on the side that is not an arrow head?

@damithc
Copy link
Contributor

damithc commented Dec 4, 2018

@damithc In this diagram, is there an association from Lid to Container?
I understand that arrow head indicates the navigability of an association, but I am not sure if an association hence becomes 1-way instead of 2-way.

There is an association between Lid and Container and the navigability is from Container to Lid. As the navigabiity is only in one direction, it is not a bidirectional association.

@damithc
Copy link
Contributor

damithc commented Dec 4, 2018

In an association that is only navigable in one-direction, should we ever have a multiplicity on the side that is not an arrow head?

You can have multiplicity on either end of the association irrespective of navigability as each association has two multiplicities e.g., in the made by association between Car and Company the two multiplicities are,

  1. How many Car objects can be made by one Company?
  2. How many Compnaies could be involved in making a given Car object?

@pengnam
Copy link

pengnam commented Dec 4, 2018

@damithc

Thank you!

https://user-images.githubusercontent.com/28092058/49424982-3a1fec00-f7d7-11e8-91e4-10faaef188ba.png

To make sure that I am on the same page:
In the case of the diagram above, a student can be part of 1 to 3 teams? Even if this multiplicity can't be enforced.

@damithc
Copy link
Contributor

damithc commented Dec 4, 2018

To make sure that I am on the same page:
In the case of the diagram above, a student can be part of 1 to 3 teams? Even if this multiplicity can't be enforced.

Yes, that's correct. It is not impossible to enforce this multiplicity either e.g., we can write code to go through the entire object structure to ensure no student is part of more than three teams.

@pengnam
Copy link

pengnam commented Dec 5, 2018

@damithc Thank you

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