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
相关阅读
new thread object 占的是heap还是stack?Hibernate sequences questionJAVA文本文件读写问题JAVA问题求教哪里有比较好的UML实战教程Comparator Accessor method for SortedSet1999年出版的C,C++,Java语言教程过期了吗??请教:AXIS 1.4 webservice client using a proxyWhy My Java Program Is So Slow?Scaling Your Java EE Applications在自己的电脑上建一个类似BBS的系统,请问有没有比较好的Java请问Java 6.0 compliance level is unsupported什么意思?问个java certificate的问题JAVA新手问题请教Sun exam retake promoxml to PDF的packageJava,EJB的performanceweird problem with DynaForm on strutsspring/hibernate/ajax/web 2.0/bpel booksJob Opportunity: Java Developer