记下一些需要反复阅读的点_代码大全书评-查字典图书网
查字典图书网
当前位置: 查字典 > 图书网 > 程序 > 代码大全 > 记下一些需要反复阅读的点
forsee 代码大全 的书评 发表时间:2015-12-03 15:12:11

记下一些需要反复阅读的点

每天读一点,随手记下些东西,权当索引,懒得打字,直接从英文电子版复制了。页码对应中文第2版
P146 如果派生后覆写了某方法,但在其中没做任何事,应该参考以下内容
Be suspicious of classes that override a routine and do nothing inside the derived routine

The place to fix this problem is not in the base class, but in the original Cat class. Create a Claws class and contain that within the Cats class, or build a constructor for the class that includes whether the cat scratches. The root problem was the assumption that all cats scratch, so fix that problem at the source, rather than just bandaging it at the destination.
P149 关于使用继承还是包含的建议
If multiple classes share common data but not behavior, then create a common object that those classes can contain.
● If multiple classes share common behavior but not data, then derive them from a common base class that defines the common routines.
● If multiple classes share common data and behavior, then inherit from a common base class that defines the common data and routines.
● Inherit when you want the base class to control your interface; contain when you want to control your interface.

P170 逻辑上的内聚性
P171 好的子程序名字
P305 把枚举类型的第一个元素留做非法值

展开全文
有用 0 无用 0

您对该书评有什么想说的?

发 表

推荐文章

猜你喜欢

附近的人在看

推荐阅读

拓展阅读