• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Difference between Dependency and Association

 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Talented Ranchers,

Can anyone tell me the difference between Dependency and Association in class diagrams ?


Thanks for your time,
Sai
 
Ranch Hand
Posts: 952
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think there are two types of Association : 1) Aggregation 2) Composition

1) Aggregation : I think you can think Aggregation part as Dependency. When a Car class need Tyres , and these tyres are provided to Car constructor from outside when constructing the Car object, then your Car class is dependent on the car list.
As in this example client of Car has to pass tyreList to its constructor.



2) Composition : When your Car class need not its client to pass anything to it, means you Car class will make its tyres itself, then it is using Composition. Here different types of dependency used, here Car is dependent on the Tyre class, not on its Client class to provide him tyres. So you can say Aggregation are more dependent on its client and tyres. While composition is not dependent on its client.


I think Association uses Dependency to work. So Association is the client of Dependency, think without any type dependency how Association will work?
 
Sai Swami
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got the answer from ThoughtWorks web site:

Dependency is a loose form of Association. It is "optional" to show dependency in class diagrams. It is represented by a dotted arrow.

Thanks for the answer anyways,
Sai
 
Think of how stupid the average person is. And how half of them are stupider than that. But who reads this tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic