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).About 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.About 12 years ago
-
Inheritance makes changing the definition of the method and sub-classes easier. I am the 1%, I enjoy inheritance.About 12 years ago
-
One reason is you can change the object at runtime. Also, extendeding two classes is messy.About 12 years ago
-
Inheritance would cause the commandCar to be a car, instead of a controller which is what it seems to be.About 12 years ago
-
You have more control over the object with composition vs. inheritance.About 12 years ago
-
Composition allows CommandCar to inherit another classAbout 12 years ago
-
Composition allows multiple implementations.About 12 years ago
-
1) You can extend your own class if you aren't using inheritance (lack of multiple inheritance in Java).About 12 years ago
-
Change the object at runtimeAbout 12 years ago
Powered by