 Thursday, March 24, 2005
From Holub on Patterns:
The prime directive of OO systems is as follows:
Never ask an object for information that you need to
do something; rather, ask the object that has the information to
do the work for
you.
Ken Arnold says, "Ask for help, not for information."
-
Objects are defined by "contract." They don't violate their contract.
-
All data is private. Period. (This rule applies to all implementation details, not just the data.)
-
It must be possible to make any change to the way
an object is implemented, no matter how significant that change, by
modifying the single class that defines that object.
-
"Get" and "set" functions are evil when used
blindly (when they're just elaborate ways to make the data public).
I've a lot more to say on this issue later in the "Getters and Setters
Are Evil" section.
|