Composition
Build classes from other objects ("has-a") instead of inheriting ("is-a").
Easy
A Robot has Motors and a Battery. "Favour composition over inheritance" — more flexible and easier to test.
Spotted a mistake or want to add detail? Suggest an improvement — Content Contributors' edits are reviewed by editors before they go live.
Discussion (0)
Sign in or join free to ask questions and discuss this topic.