NOTE
Composition Reuse Principle
Composite reuse favors composition or aggregation over inheritance. These notes examine code reuse and extension through that principle.
This is a historical learning note and may contain outdated or incomplete understanding.
1. What Is the Composition Reuse Principle?
Use composition or aggregation relationships for code reuse whenever possible, and use inheritance less.
It applies the open–closed principle to composition/aggregation.
2. Why Is the Composition Reuse Principle Needed?
Improve software reusability through composition.
3. Implementing the Composition Reuse Principle
Inject the new object as an attribute of the existing object.
4. References
Drag to pan, scroll to zoom, and click a node to expand or collapse it. Large maps start with deeper levels collapsed; click nodes to expand them.
Discussion
Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub