wood burning stoves 2.0*
The moose likes OO, Patterns, UML and Refactoring and the fly likes Difference between Dependency and Association Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "Difference between Dependency and Association" Watch "Difference between Dependency and Association" New topic
Author

Difference between Dependency and Association

Sai Swami
Ranch Hand

Joined: Sep 24, 2002
Posts: 51
Hi Talented Ranchers,

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


Thanks for your time,
Sai
Punit Singh
Ranch Hand

Joined: Oct 16, 2008
Posts: 952
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?


SCJP 6
Sai Swami
Ranch Hand

Joined: Sep 24, 2002
Posts: 51
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between Dependency and Association
 
Similar Threads
Association and dependency
dependency vs association
dependency vs association again???
Difference between Dependency and Association
difference between dependency and association