Win a copy of Building Blockchain Apps this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

Association and Dependency

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,
anyone knows the distiction between these two? when do we need these two? and importantly, how do we implement these two relationships in codes? any examples for the clarification?
I would appreciate your help. Thanks.
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You might post your question at:
https://coderanch.com/forums/f-9/patterns

Nick
 
Ranch Hand
Posts: 142
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Association means two classes have relationship. For example Employees report to Manager , Students registered a Course etc... For example we
can have
class Employee
{
class Manager mDirectManager ;

}

Dependency means one class depends on another one. They do not have to be associated. The dependency can be a parameter type etc.

For example

Class AnyClass
{
public void anyMethod(Class AnyOtherClass b)
{
System.out.println(b.getName());
}

}

if the AnyOtherClass removed its getName() method , the AnyClass should be changed. Except in the anyMethod the AnyClass does not use AnyOtherClass.
This is an dependency.

Hope this help. You can find detail information about this from Apply UML and Patterns.

Thanks

Lin
 
They weren't very bright, but they were very, very big. Ad contrast:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!