Objects and data structures 数据对象与数据结构
Hide internal structure.
Prefer data structures.
Avoid hybrids structures (half object and half data).
Should be small.
Do one thing.
Small number of instance variables.
Base class should know nothing about their derivatives.
Better to have many functions than to pass some code into a function to select a behavior.
Prefer non-static methods to static methods.
隐藏内部结构。
数据结构优于数据对象。
不要使用混合结构(一半对象,一半数据)。
小。
只做一件事情。
尽量少的实例变量。
基类无需了解子类。
在选择行为时,多个函数优于传递代码到一个函数。
非static方法优于static方法。
Last updated
Was this helpful?