Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dependency vs Association

 
Eric Lefurge
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Folks
I am doing my partII assignment and having a tough time trying to distinguish if a relationship is either a dependency or association.
I know the definitions, any insights or rules of thumb that I can use from a practical perspective???
Eric
 
Victor Htet
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
Association is stronger than dependency. Association can be further specified as extends, implements, aggregation relationships.
From programming point of view, if you use class A as a paramater of a method or return type of a method in class B, then class B has dependency relationship with class A.
Victor
SCJP, SCWCD, SCEA
 
Eric Lefurge
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Victor
On the same note, say a class A instantiates Class B and calls its methods, then its an association ??

-@RIC
 
Rufus BugleWeed
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That could be stronger than association. It might
be aggregation or composition.
The experts disagree about what's what.
 
Victor Htet
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
Don't think too deep. I mean don't think at very detailed level. If you want to think in detail, do it with the following perspectives:
1) does class A hold class B as member variable?
2) does class A extends class B
3) does class A implements interface C
4) does class A's methods depend on class B or does changes to class B reflect class A behavior?

I highly suggest you design your system not in very detail level.
 
Eric Lefurge
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Victor , Rufus
Thanks for ur suggestions.
One more clarification, So does it imply that relationships are implementation dependant and varies from each person who designed the application???
eRIC
 
Victor Htet
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eric,
No. Your design should be as less implementation dependent as possible. But for assignment, you can stick to J2EE implementation perspective.
Yes. It varies from each person who designed the application??? Every design is unique for each architect.
 
Sanjay Raghavan
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the strictest UML sense, I would not term 'extends' or 'implements' as association. They indicate relashionships between classes, but not association.
There are 4 types of relashionships - Association (Aggregation and Composition are stronger forms), Dependency, Generalization (extends) and realization (via implements or via delegation.)
For more on association and the stronger forms check threads:
http://www.coderanch.com/t/149591/java-Architect-SCEA/certification/UML-composition-vs-aggregation
http://www.coderanch.com/t/150298/java-Architect-SCEA/certification/Aggregation-Composition
HTH.
 
Rufus BugleWeed
Ranch Hand
Posts: 1551
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A UML diagram is implemetatin dependent. UML
Modeling is like speaking a language. It's
a new language and different speakers do things
different ways.
Peter Coad gave an example of aggregation
as the relationship between an organization and
its clerks; Jim Rumbaugh stated that a company
is not an aggregation of its employees. When
gurus can't agree what are we to do?

from UML Distilled by Addison-Wesley
 
Eric Lefurge
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for ur insight folks, if was very helpfull.
Now I feel like I am relationships expert, jus kidding.
eRIC
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic