Java开发网 Java开发网
注册 | 登录 | 帮助 | 搜索 | 排行榜 | 发帖统计  

您没有登录

» Java开发网 » Design Pattern & UML  

按打印兼容模式打印这个话题 打印话题    把这个话题寄给朋友 寄给朋友    该主题的所有更新都将Email到你的邮箱 订阅主题
flat modethreaded modego to previous topicgo to next topicgo to back
作者 依赖(dependency)与关联(association)的区别?
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-11-02 13:18 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
应用时难分辨,各位有经验的说说

jameszhang edited on 2004-11-02 13:22

"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:依赖(dependency)与关联(association)的区别? [Re:jameszhang]
牛老板



发贴: 0
积分: 0
于 2004-11-02 13:26 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
好象有个什么图书馆,书,书的页的例子....



作者 Re:依赖(dependency)与关联(association)的区别? [Re:jameszhang]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-11-02 13:36 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list



"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:依赖(dependency)与关联(association)的区别? [Re:jameszhang]
牛老板



发贴: 0
积分: 0
于 2004-11-02 13:50 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
好象是这本书.

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


牛老板 edited on 2004-11-02 13:52


作者 Re:依赖(dependency)与关联(association)的区别? [Re:jameszhang]
kavinwang

现实版流氓兔

版主


发贴: 529
积分: 38
于 2004-11-02 13:53 user profilesend a private message to usersend email to kavinwangsearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
据个例子:

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

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



作者 Re:依赖(dependency)与关联(association)的区别? [Re:jameszhang]
scud



CJSDN高级会员


发贴: 108
积分: 10
于 2004-11-02 14:49 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list


scud edited on 2004-11-03 09:10

作者 Re:依赖(dependency)与关联(association)的区别? [Re:scud]
helloworld



发贴: 0
积分: 0
于 2004-11-02 23:15 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
http://community.csdn.net/Expert/topic/3478/3478564.xml?temp=.9224817



作者 Re:依赖(dependency)与关联(association)的区别? [Re:kavinwang]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-11-03 08:48 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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();为依赖
可能不太正确,我想也差不多,很长时间对这些具体内容不管不问,都忘了。


经过验证很对,呵呵


jameszhang edited on 2004-11-03 09:13

"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:依赖(dependency)与关联(association)的区别? [Re:jameszhang]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-11-03 08:55 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
引自 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();
}
}



"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"

作者 Re:依赖(dependency)与关联(association)的区别? [Re:jameszhang]
shawnma





发贴: 46
积分: 0
于 2004-11-04 16:51 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
同意楼上的,另方法的参数,类方法也是一种依赖关系。


作者 Re:依赖(dependency)与关联(association)的区别? [Re:jameszhang]
robin

超级水鬼



发贴: 128
积分: 19
于 2004-11-08 08:56 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
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最近表现不是很积极呀。忙什么呢?



作者 Re:依赖(dependency)与关联(association)的区别? [Re:robin]
jameszhang



CJSDN高级会员


发贴: 1594
积分: 111
于 2004-11-08 15:31 user profilesend a private message to usersearch all posts byselect and copy to clipboard. 
ie only, sorry for netscape users:-)add this post to my favorite list
robin wrote:
james最近表现不是很积极呀。忙什么呢?

俩字: 消极!



"First they ignore u, then they laugh at u, then they fight u, then u will win

Mahatma Gandhi"


flat modethreaded modego to previous topicgo to next topicgo to back
  已读帖子
  新的帖子
  被删除的帖子
Jump to the top of page

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