Activity is now locked.
Responses are not accepted at this time.
Why do we favor composition over inheritance?
-
With composition, a single car can have multiple commands (start and stop).Over 12 years ago
-
2) If you use inheritance, all of the public methods/attributes of Car would be visible from your class. With inheritance, you can choose what is visible.Over 12 years ago
-
Inheritance makes changing the definition of the method and sub-classes easier. I am the 1%, I enjoy inheritance.Over 12 years ago
-
One reason is you can change the object at runtime. Also, extendeding two classes is messy.Over 12 years ago
-
Inheritance would cause the commandCar to be a car, instead of a controller which is what it seems to be.Over 12 years ago
-
You have more control over the object with composition vs. inheritance.Over 12 years ago
-
Composition allows CommandCar to inherit another classOver 12 years ago
-
Composition allows multiple implementations.Over 12 years ago
-
1) You can extend your own class if you aren't using inheritance (lack of multiple inheritance in Java).Over 12 years ago
-
Change the object at runtimeOver 12 years ago
Powered by