October 2004
Intermediate to advanced
240 pages
6h 22m
English
Don’t volunteer too much: Avoid returning handles to internal data managed by your class, so clients won’t uncontrollably modify state that your object thinks it owns.
Consider:

Data hiding is a powerful abstraction and modularity device (see Items 11 and 41). But hiding data and then giving away handles to it is self-defeating, just like locking your house and leaving the keys in the lock. This is because:
• Clients now have two ways to implement functionality: They can use your class’s abstraction (Socket) or directly manipulate the implementation that your class relies on (the socket’s ...