摘要: Properly constructed classes are designed in two parts—the interface and the implementation.Perhaps the most important issue when designing a class is identifying the audience, or users, of the class.... 阅读全文
posted @ 2005-09-01 16:32 枫 阅读(612) 评论(0) 推荐(0) 编辑
摘要: 如果你确定两件对象之间是is-a的关系,那么此时你应该使用继承;比如菱形、圆形和方形都是形状的一种,那么他们都应该从形状类继承而不是聚合。如果你确定两件对象之间是has-a的关系,那么此时你应该使用聚合;比如电脑是由显示器、CPU、硬盘等组成的,那么你应该把显示器、CPU、硬盘这些类聚合成电脑类,而不是从电脑类继承。 阅读全文
posted @ 2005-09-01 12:42 枫 阅读(4903) 评论(3) 推荐(0) 编辑