Talk:Association versus Dependency

From CSSEMediaWiki
(Difference between revisions)
Jump to: navigation, search
(Confused)
Line 1: Line 1:
 
As long as [[Design by contract]] is followed, does the difference really matter? This page needs more examples. --[[User:MartinvanZijl|MartinvanZijl]] 03:58, 20 August 2010 (UTC)
 
As long as [[Design by contract]] is followed, does the difference really matter? This page needs more examples. --[[User:MartinvanZijl|MartinvanZijl]] 03:58, 20 August 2010 (UTC)
  
== Confused ==
 
  
 
I'm kind of confused with this issue, actually. Does anybody have a clear explanation on when we should use a dependency and when should use an association? Right now I tend to use a dependency only when a change in one class would affect another. If two classes only knows about each other like one calls another then I use an association. But I'm only following my hunches, does anyone knows a more decisive explanation than the one here? A Google search only contributed more to my confusion: [http://www.coderanch.com/t/100655/patterns/association-vs-dependency 1] [http://www.coderanch.com/t/97655/patterns/Dependency-vs-Association 2] --[[User:Mujtaba Alshakhouri|Mujtaba Alshakhouri]] 12:27, 24 September 2010 (UTC)
 
I'm kind of confused with this issue, actually. Does anybody have a clear explanation on when we should use a dependency and when should use an association? Right now I tend to use a dependency only when a change in one class would affect another. If two classes only knows about each other like one calls another then I use an association. But I'm only following my hunches, does anyone knows a more decisive explanation than the one here? A Google search only contributed more to my confusion: [http://www.coderanch.com/t/100655/patterns/association-vs-dependency 1] [http://www.coderanch.com/t/97655/patterns/Dependency-vs-Association 2] --[[User:Mujtaba Alshakhouri|Mujtaba Alshakhouri]] 12:27, 24 September 2010 (UTC)
 +
 +
 +
I agree Martin, if [[Design by contract]] is followed rigidly then dependancies don't really matter. But that is providing you get your contract perfect first time and don't need to revise it. Considering Association vs Dependency, don't they refer to different things? I was under the impression that '''Associations''' were a relationship between two classes, either unidirectional or bidirectional, and that as a result one class was '''dependent''' on the interface/name of the other. So if you change something about a class then you need to update any class that is dependent on the changed class. --[[User:John Hofman|John Hofman]]

Revision as of 09:48, 27 September 2010

As long as Design by contract is followed, does the difference really matter? This page needs more examples. --MartinvanZijl 03:58, 20 August 2010 (UTC)


I'm kind of confused with this issue, actually. Does anybody have a clear explanation on when we should use a dependency and when should use an association? Right now I tend to use a dependency only when a change in one class would affect another. If two classes only knows about each other like one calls another then I use an association. But I'm only following my hunches, does anyone knows a more decisive explanation than the one here? A Google search only contributed more to my confusion: 1 2 --Mujtaba Alshakhouri 12:27, 24 September 2010 (UTC)


I agree Martin, if Design by contract is followed rigidly then dependancies don't really matter. But that is providing you get your contract perfect first time and don't need to revise it. Considering Association vs Dependency, don't they refer to different things? I was under the impression that Associations were a relationship between two classes, either unidirectional or bidirectional, and that as a result one class was dependent on the interface/name of the other. So if you change something about a class then you need to update any class that is dependent on the changed class. --John Hofman

Personal tools