Topic: 依赖关系

  Print this page

1.依赖关系 Copy to clipboard
Posted by: coolbaby
Posted on: 2005-03-01 08:40

在A类的一个方法中创建了一个b的实例,并调用了b的一个方法,那么A和b的关系是不是依赖?不能算关联吧

2.Re:依赖关系 [Re: coolbaby] Copy to clipboard
Posted by: robin
Posted on: 2005-03-16 14:08

你的b是不是A的成员属性?如果是成员属性的话,那么它跟A就是关联关系,如果不是成员属性那么就是依赖关系。

3.Re:依赖关系 [Re: coolbaby] Copy to clipboard
Posted by: waterflower
Posted on: 2005-03-21 11:28

不知道robin有没有用过together或者下面我描述的问题在任何工具中都是好一样的。
每次建立一个关联,系统会为该关联自动生成一个带Lnk前缀的名字,但是在类图中这个名字不会以属性出现在client class中,但是如果在属性中除去Lnk前缀,该关连会以属性出现在类图中。不是很理解?或者说我的问题是该如何给关联取名,什么时候应该保留Lnk前缀,什么时候应该去掉?

4.Re:依赖关系 [Re: coolbaby] Copy to clipboard
Posted by: idol
Posted on: 2005-03-22 01:04

楼主你的说法很明显是依赖关系,
你是在你的操作中(method)创建了一个b的实例,并调用了b的一个方法

5.Re:依赖关系 [Re: waterflower] Copy to clipboard
Posted by: spi_cn
Posted on: 2005-03-22 10:09

waterflower wrote:
不知道robin有没有用过together或者下面我描述的问题在任何工具中都是好一样的。
每次建立一个关联,系统会为该关联自动生成一个带Lnk前缀的名字,但是在类图中这个名字不会以属性出现在client class中,但是如果在属性中除去Lnk前缀,该关连会以属性出现在类图中。不是很理解?或者说我的问题是该如何给关联取名,什么时候应该保留Lnk前缀,什么时候应该去掉?

据我所知,lnk前缀应该是together所特有的,目的是将关联导航方向的设计后置。一般来说在分析阶段,往往很难确定关联的导航方向,使用带有lnk前缀的关联,将不会在类中将关联生成属性;在设计阶段,将lnk前缀去掉,并标明关联的导航方向,此时将关联生成类的属性

6.Re:依赖关系 [Re: coolbaby] Copy to clipboard
Posted by: waterflower
Posted on: 2005-03-23 07:40

多谢spi_cn的解释,我好像有点明白together为什么这么干了。

7.Re:依赖关系 [Re: coolbaby] Copy to clipboard
Posted by: waterflower
Posted on: 2005-03-23 07:42

其实在Window->Preferences->Modeling->Java->Associations中关联的前缀设置是lnk,你可以进行修改。
这是别人回复我的问题
By default the prefix is set to "ink" and the way of attributes displaying
is "Automatic" (We can change association link prefix and other properties
in Window->Preferences->Modeling->Java->Associations).
That means that if we create an association then the corresponding attribute
is created with the pointed prefix in code and this attribute is shown in
the model only as association link. In other words, if you need to see
associations only as accociation links in the model then you should use
prefixes in attribute namings. If you want to see also attributes in the
model then you shouldn't write prefixes in attribute namings.

8.Re:依赖关系 [Re: coolbaby] Copy to clipboard
Posted by: AKA
Posted on: 2005-04-13 00:08

记得依赖关系的描述,好象是一个类是不是根据另一个类的变化而变化,以此来作为判断的准则的


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