j**7 发帖数: 59 | 1 不好意思,刚才不小心把第一个版本删除了
上来好几个 behavior 问题,一般 behavior 问题我不怎么准备,答的很简略,都是常
见的问题,我就不列了。
c++ and data structure
** single linked list, find nth from the end
** Overwriting and Overloading
** Stack vs. Queue
** Array of integers, all integers appear even times except one, find the
one appears odd times. (some following up questions for this one)
OOD
** Do you approve the following design?
Class Furniture{
Some functions related to the property of furnitures;
};
4 classes derived from Furniture
Cla |
c*********n 发帖数: 1057 | 2 还真是Amazon啊呵呵,感觉前面的几个技术题都不是太难啊
【在 j**7 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 不好意思,刚才不小心把第一个版本删除了 : 上来好几个 behavior 问题,一般 behavior 问题我不怎么准备,答的很简略,都是常 : 见的问题,我就不列了。 : c++ and data structure : ** single linked list, find nth from the end : ** Overwriting and Overloading : ** Stack vs. Queue : ** Array of integers, all integers appear even times except one, find the : one appears odd times. (some following up questions for this one) : OOD
|
i****h 发帖数: 321 | 3 请问OOD那个问题应该怎么回答啊?
Interface Segregation Principle?
The dependency of one class to another one should depend on the smallest
possible interface |
g*******y 发帖数: 1930 | 4 I would prefer decorator
【在 i****h 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 请问OOD那个问题应该怎么回答啊? : Interface Segregation Principle? : The dependency of one class to another one should depend on the smallest : possible interface
|
f******g 发帖数: 13917 | 5 我也觉得应该是decorator。
【在 g*******y 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I would prefer decorator
|
f****b 发帖数: 486 | 6 my understanding is decorator pattern assumes decorators (wood, steel and pl
astic) could be applied to the objects (chair, desk, table etc) in any combi
nation, but that's not the case because a furniture cannot be both wood and
steel
i think strategy is more appropriate
【在 g*******y 的大作中提到】![](/moin_static193/solenoid/img/up.png) : I would prefer decorator
|
j**7 发帖数: 59 | 7 这个问题是个改错题,这个问题面试的人并没有问我要用什么 Pattern。
一开始没想清楚,说用 multiple inheritance,
但是他不满意,后来意思到 material 只是家具一个属性,不应该出现在 base class 里, 所以不用 multiple inheritance。
至于 a furniture made of multiple materials like steel, wood,我答的是 把家
具 分解成 parts,他就满意了。
可能问我的问题简单,感觉考点就是明白 OO 里最基本的概念:is-a 和 has-a,系统是不是 scalable
【在 i****h 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 请问OOD那个问题应该怎么回答啊? : Interface Segregation Principle? : The dependency of one class to another one should depend on the smallest : possible interface
|
j**7 发帖数: 59 | 8 我只道 Array of integers 是个老题,不过有个问题问大家:
Hash table 和 XOR 那个快?有没有人试过?
XOR 的 bit operation 有没有办法并行计算?
Array of integers, all integers appear even times except one, find the one
appears odd times |
P***y 发帖数: 2885 | 9
pl
combi
and
Decorator pattern is used to solve the "coffee shop" problem, in which a lar
ge number of different yet similar objects can be derived through unlimitted
combinations.
In this case, I would consider to insert one layer of abstrations like chair
, between furniture and plastic chair.
【在 f****b 的大作中提到】![](/moin_static193/solenoid/img/up.png) : my understanding is decorator pattern assumes decorators (wood, steel and pl : astic) could be applied to the objects (chair, desk, table etc) in any combi : nation, but that's not the case because a furniture cannot be both wood and : steel : i think strategy is more appropriate
|
g***i 发帖数: 408 | 10 这是一个典型的桥模式,
http://www.netobjectives.com/files/design-patterns-explained-ch10.pdf
The original design has the problems that if you want to add a Desk,
then
you have to add too class: WoodDesk and SteelDesk.
If you can use bridge pattern
把 material (WOOD,STEEL...) 和 style (DESK,TABLE...)作为家具的property,在
创建家具的时候这样就可以自由的组合
不同的MATERIAL和STYLE. 这也是对自然世界最确切的建模。
装饰模式用在这里有点霸王硬上攻了。
class 里,
所以不用 multiple inheritance。
家
统是不是
scalable
【在 j**7 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 这个问题是个改错题,这个问题面试的人并没有问我要用什么 Pattern。 : 一开始没想清楚,说用 multiple inheritance, : 但是他不满意,后来意思到 material 只是家具一个属性,不应该出现在 base class 里, 所以不用 multiple inheritance。 : 至于 a furniture made of multiple materials like steel, wood,我答的是 把家 : 具 分解成 parts,他就满意了。 : 可能问我的问题简单,感觉考点就是明白 OO 里最基本的概念:is-a 和 has-a,系统是不是 scalable
|
|
|
r********t 发帖数: 395 | 11 agree. Not that complex...
The testing point is to disapprove the idea of xxx_yyyy, where xxx us the
texture and yyyy is the furniture. Because this way of designing is
not optimal polymorphism. : 把 material (WOOD,STEEL...) 和 style (DESK,
TABLE...)作为家具的property,在 |
r********t 发帖数: 395 | 12 do ya have specific questions for Overwriting and Overloading??
【在 j**7 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 不好意思,刚才不小心把第一个版本删除了 : 上来好几个 behavior 问题,一般 behavior 问题我不怎么准备,答的很简略,都是常 : 见的问题,我就不列了。 : c++ and data structure : ** single linked list, find nth from the end : ** Overwriting and Overloading : ** Stack vs. Queue : ** Array of integers, all integers appear even times except one, find the : one appears odd times. (some following up questions for this one) : OOD
|
m******9 发帖数: 968 | |
j**7 发帖数: 59 | 14 Nothing specific, just asked "tell me about Overwriting and Overloading"
【在 r********t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : do ya have specific questions for Overwriting and Overloading??
|
k********0 发帖数: 585 | 15 AGREE! A basic rule: favor composition over inheritance!
【在 r********t 的大作中提到】![](/moin_static193/solenoid/img/up.png) : agree. Not that complex... : The testing point is to disapprove the idea of xxx_yyyy, where xxx us the : texture and yyyy is the furniture. Because this way of designing is : not optimal polymorphism. : 把 material (WOOD,STEEL...) 和 style (DESK, : TABLE...)作为家具的property,在
|
n********u 发帖数: 194 | 16 好答案~~
多谢~
【在 g***i 的大作中提到】![](/moin_static193/solenoid/img/up.png) : 这是一个典型的桥模式, : http://www.netobjectives.com/files/design-patterns-explained-ch10.pdf : The original design has the problems that if you want to add a Desk, : then : you have to add too class: WoodDesk and SteelDesk. : If you can use bridge pattern : 把 material (WOOD,STEEL...) 和 style (DESK,TABLE...)作为家具的property,在 : 创建家具的时候这样就可以自由的组合 : 不同的MATERIAL和STYLE. 这也是对自然世界最确切的建模。 : 装饰模式用在这里有点霸王硬上攻了。
|