• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

Association and Dependency

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic