Topic: 依赖(dependency)与关联(association)的区别?

  Print this page

1.依赖(dependency)与关联(association)的区别? Copy to clipboard
Posted by: jameszhang
Posted on: 2004-11-02 13:18

应用时难分辨,各位有经验的说说

2.Re:依赖(dependency)与关联(association)的区别? [Re: jameszhang] Copy to clipboard
Posted by: 牛老板
Posted on: 2004-11-02 13:26

好象有个什么图书馆,书,书的页的例子....

3.Re:依赖(dependency)与关联(association)的区别? [Re: jameszhang] Copy to clipboard
Posted by: jameszhang
Posted on: 2004-11-02 13:36


4.Re:依赖(dependency)与关联(association)的区别? [Re: jameszhang] Copy to clipboard
Posted by: 牛老板
Posted on: 2004-11-02 13:50

好象是这本书.

http://www.china-pub.com/computers/common/info.asp?id=8101

5.Re:依赖(dependency)与关联(association)的区别? [Re: jameszhang] Copy to clipboard
Posted by: kavinwang
Posted on: 2004-11-02 13:53

据个例子:

class A{
public B b=new B();
A(){
}
public void somefun(){
C c = new C();
}
}

其中:
public B b=new B();为关联
C c = new C();为依赖
可能不太正确,我想也差不多,很长时间对这些具体内容不管不问,都忘了。

6.Re:依赖(dependency)与关联(association)的区别? [Re: jameszhang] Copy to clipboard
Posted by: scud
Posted on: 2004-11-02 14:49


7.Re:依赖(dependency)与关联(association)的区别? [Re: scud] Copy to clipboard
Posted by: helloworld
Posted on: 2004-11-02 23:15

http://community.csdn.net/Expert/topic/3478/3478564.xml?temp=.9224817

8.Re:依赖(dependency)与关联(association)的区别? [Re: kavinwang] Copy to clipboard
Posted by: jameszhang
Posted on: 2004-11-03 08:48

kavinwang wrote:
据个例子:

class A{
public B b=new B();
A(){
}
public void somefun(){
C c = new C();
}
}

其中:
public B b=new B();为关联
C c = new C();为依赖
可能不太正确,我想也差不多,很长时间对这些具体内容不管不问,都忘了。


经过验证很对,呵呵

9.Re:依赖(dependency)与关联(association)的区别? [Re: jameszhang] Copy to clipboard
Posted by: jameszhang
Posted on: 2004-11-03 08:55

引自 helloword 提供 http://community.csdn.net/Expert/topic/3478/3478564.xml?temp=.9224817
依赖一般的表现方法是方法的局部变量,或者是方法内对静态方法的引用!
关联一般的表现方法是对象的全局变量!

依赖:
class A
{
void methodA()
{
B b = new B();
b.methodB();
}
}
关联:
class A
{
B b = new B();
void methodA()
{
b.methodB();
}
}

10.Re:依赖(dependency)与关联(association)的区别? [Re: jameszhang] Copy to clipboard
Posted by: shawnma
Posted on: 2004-11-04 16:51

同意楼上的,另方法的参数,类方法也是一种依赖关系。

11.Re:依赖(dependency)与关联(association)的区别? [Re: jameszhang] Copy to clipboard
Posted by: robin
Posted on: 2004-11-08 08:56

jameszhang wrote:
引自 helloword 提供 http://community.csdn.net/Expert/topic/3478/3478564.xml?temp=.9224817
依赖一般的表现方法是方法的局部变量,或者是方法内对静态方法的引用!
关联一般的表现方法是对象的全局变量!

依赖:
class A
{
void methodA()
{
B b = new B();
b.methodB();
}
}
关联:
class A
{
B b = new B();
void methodA()
{
b.methodB();
}
}


james最近表现不是很积极呀。忙什么呢?

12.Re:依赖(dependency)与关联(association)的区别? [Re: robin] Copy to clipboard
Posted by: jameszhang
Posted on: 2004-11-08 15:31

robin wrote:
james最近表现不是很积极呀。忙什么呢?

俩字: 消极!


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2020 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号
客服电话 0592-8750026    客服信箱 714923@qq.com    客服QQ 714923