How does composition promote code reusability?
Composition promotes code reusability by allowing developers to create new functionality by combining existing objects, reducing the need to write new code from scratch.
What is the difference between composition and inheritance?
The difference is that composition involves building objects from other objects, while inheritance involves creating a new class based on an existing class. Composition provides more flexibility and modularity.
Why is composition favored over inheritance in modern software design?
Composition is favored over inheritance because it allows for more flexible and modular designs, avoiding the pitfalls of tight coupling and promoting better code maintainability.