Next: Minimize the number
Up: Principles
Previous: Identify and encapsulate
- One can reuse a component's interface (design) or
implementation (code) or both.
- Reusable component = multiple users = single interface with
multiple implementations. Each interface can have multiple
implementations.
- Enhances verifiability, locality, prevention of
side-effects, future evolution, subclassibility, and eases
change of components,
- Languages vary widely in support of the principle. E.g., Ada
package specification, C++ abstract classes, and C header
files, as do techniques for exploiting them.
- Use interface specification as a barrier to access the
implementation.
- Don't let client break the component abstraction defined by the
interface.
- When possible, use value arguments and results, not pointers or
references that reveal helpers or other internal features.
- Use authentication measures in cases where you must export
(e.g., friends in C++).
Doug Lea
Sat Apr 8 09:58:22 EDT 1995