c*o
3 楼
thanks.
我就觉得题目比较模糊.不知道它是不是想考概念.
而且我觉得用instance variable.改变的永远是instance,跟c没关系啊.c的instance永远不能直接用ab
的功能.
我就觉得题目比较模糊.不知道它是不是想考概念.
而且我觉得用instance variable.改变的永远是instance,跟c没关系啊.c的instance永远不能直接用ab
的功能.
c*o
6 楼
I got it.
c*t
8 楼
is-a / has-a 其实并不是好的概念。这个东西的使用范围是 non-recursive
data 。所谓的 1:1,1:n 都是 relational database 上的概念。而 relational
database 的适用范围很窄。所以并不适合 class design 。
同时,表面上 inheritance 从定义上就是 is-a ,而 composition 就是
has-a,但是这两个概念并不是 mutually exclusive 的概念(在 relational
database 里则是)。
例子:
class A : implements B
{
private B b;
A () { this (null); }
A (B other) { b = other; }
public void action () { if (b == null) foo (); else b.action (); }
...
}
这种情况下,这种 composition 其实同时是 is-a 也是 has-a 。所以简单的
用 is-a / has-a
【在 S*********t 的大作中提到】
: 我猜 这个是考 is-a 和 has-a 的区别。
: inheritance vs. composition
:
: 永远不能直接用ab
data 。所谓的 1:1,1:n 都是 relational database 上的概念。而 relational
database 的适用范围很窄。所以并不适合 class design 。
同时,表面上 inheritance 从定义上就是 is-a ,而 composition 就是
has-a,但是这两个概念并不是 mutually exclusive 的概念(在 relational
database 里则是)。
例子:
class A : implements B
{
private B b;
A () { this (null); }
A (B other) { b = other; }
public void action () { if (b == null) foo (); else b.action (); }
...
}
这种情况下,这种 composition 其实同时是 is-a 也是 has-a 。所以简单的
用 is-a / has-a
【在 S*********t 的大作中提到】
: 我猜 这个是考 is-a 和 has-a 的区别。
: inheritance vs. composition
:
: 永远不能直接用ab
t*e
9 楼
What you described here is a Gof composite pattern.
Recursive relationship exists in relational data model.
【在 c*****t 的大作中提到】
: is-a / has-a 其实并不是好的概念。这个东西的使用范围是 non-recursive
: data 。所谓的 1:1,1:n 都是 relational database 上的概念。而 relational
: database 的适用范围很窄。所以并不适合 class design 。
: 同时,表面上 inheritance 从定义上就是 is-a ,而 composition 就是
: has-a,但是这两个概念并不是 mutually exclusive 的概念(在 relational
: database 里则是)。
: 例子:
: class A : implements B
: {
: private B b;
c*t
10 楼
Nope. In relational database, recursive relationship is nothing
more than an attribute that refers to the primary key. It doesn't
mean 1:n or has-a relationship.
Being able to store is-a and has-a of the same type would mean
hierarchical database, which doesn't fit in relationship database
well. If you can recall, the attributes of hierarhical database
must be flattened to "abc / def / ghi" type of attributes to be
stored in relational databases.
Thus to be able to store is-a and has-a of sam
【在 t*******e 的大作中提到】
:
: What you described here is a Gof composite pattern.
: Recursive relationship exists in relational data model.
more than an attribute that refers to the primary key. It doesn't
mean 1:n or has-a relationship.
Being able to store is-a and has-a of the same type would mean
hierarchical database, which doesn't fit in relationship database
well. If you can recall, the attributes of hierarhical database
must be flattened to "abc / def / ghi" type of attributes to be
stored in relational databases.
Thus to be able to store is-a and has-a of sam
【在 t*******e 的大作中提到】
:
: What you described here is a Gof composite pattern.
: Recursive relationship exists in relational data model.
F*n
11 楼
Containment and inheritance are two basic ways of reuse in OO.
In fact inheritance can be regarded as a special case of containment.
They are trying to test you OO concepts I guess.
永远不能直接用ab
【在 c**o 的大作中提到】
: thanks.
: 我就觉得题目比较模糊.不知道它是不是想考概念.
: 而且我觉得用instance variable.改变的永远是instance,跟c没关系啊.c的instance永远不能直接用ab
: 的功能.
In fact inheritance can be regarded as a special case of containment.
They are trying to test you OO concepts I guess.
永远不能直接用ab
【在 c**o 的大作中提到】
: thanks.
: 我就觉得题目比较模糊.不知道它是不是想考概念.
: 而且我觉得用instance variable.改变的永远是instance,跟c没关系啊.c的instance永远不能直接用ab
: 的功能.
F*n
12 楼
你这个例子不对,IS A 对应 Class, conceptually是一个集合
Has-a 对应的是Instance,conceptually 是 set member
所以is-a和has-a至少在Java这种分Class和Object的语言来说是严格分开的。
【在 c*****t 的大作中提到】
: is-a / has-a 其实并不是好的概念。这个东西的使用范围是 non-recursive
: data 。所谓的 1:1,1:n 都是 relational database 上的概念。而 relational
: database 的适用范围很窄。所以并不适合 class design 。
: 同时,表面上 inheritance 从定义上就是 is-a ,而 composition 就是
: has-a,但是这两个概念并不是 mutually exclusive 的概念(在 relational
: database 里则是)。
: 例子:
: class A : implements B
: {
: private B b;
Has-a 对应的是Instance,conceptually 是 set member
所以is-a和has-a至少在Java这种分Class和Object的语言来说是严格分开的。
【在 c*****t 的大作中提到】
: is-a / has-a 其实并不是好的概念。这个东西的使用范围是 non-recursive
: data 。所谓的 1:1,1:n 都是 relational database 上的概念。而 relational
: database 的适用范围很窄。所以并不适合 class design 。
: 同时,表面上 inheritance 从定义上就是 is-a ,而 composition 就是
: has-a,但是这两个概念并不是 mutually exclusive 的概念(在 relational
: database 里则是)。
: 例子:
: class A : implements B
: {
: private B b;
F*n
13 楼
我觉得把JAVA的conceptual foundation说成relational DB肯定不对,你说的问题在
Relation DB中存在但在OO设计中基本上都能解决,JAVA有很好的OO模型相反
Relational DB才不具有OO概念,所以我们才需要EJB,SPRING。JAVA对应的应该是OODB。
【在 c*****t 的大作中提到】
: Nope. In relational database, recursive relationship is nothing
: more than an attribute that refers to the primary key. It doesn't
: mean 1:n or has-a relationship.
: Being able to store is-a and has-a of the same type would mean
: hierarchical database, which doesn't fit in relationship database
: well. If you can recall, the attributes of hierarhical database
: must be flattened to "abc / def / ghi" type of attributes to be
: stored in relational databases.
: Thus to be able to store is-a and has-a of sam
Relation DB中存在但在OO设计中基本上都能解决,JAVA有很好的OO模型相反
Relational DB才不具有OO概念,所以我们才需要EJB,SPRING。JAVA对应的应该是OODB。
【在 c*****t 的大作中提到】
: Nope. In relational database, recursive relationship is nothing
: more than an attribute that refers to the primary key. It doesn't
: mean 1:n or has-a relationship.
: Being able to store is-a and has-a of the same type would mean
: hierarchical database, which doesn't fit in relationship database
: well. If you can recall, the attributes of hierarhical database
: must be flattened to "abc / def / ghi" type of attributes to be
: stored in relational databases.
: Thus to be able to store is-a and has-a of sam
i*w
14 楼
Adapter Pattern
相关阅读
能不能不系统学习Java?google map可以搜相邻区域么jquery做的水平滑动slideshow,有现成插件用吗? (转载)在手机上怎么远程控制一个房间的灯亮灯灭?分布式看什么How to: Abort DOM/XML loading when memory is low找JAVA工作问题求教java小弱请教 java -Xmx40960m纯ajax网站和sevlet优劣是啥JAVA现在最多的应用是什么?还有2~3年PhD毕业,学Java的话学哪些内容好?准备面试的侧重关于RMI的问题mongodb自带的map/reduce跟hadoop的有什么关联吗?问一个GWT里面CellBrowser无法在VerticalPanel/HorizontalPanel (转载)如何确保每次读入的字符串都是unique的改行人士 正在自学Java, JavaScript, Database Management, 等课程,寻找路同路人交流java有啥免费讲座吗?论这两年不断突破心理底线的互联网薪水 zt问个JAVA设计多线程cache问题