|
|
|
|
|
by timr
4359 days ago
|
|
"I was told about inheritance, but had to learn from other coworkers and experience that composition is much favored over inheritance." You weren't taught that, because it isn't true. Inheritance is appropriate sometimes, composition at other times. In particular, when a two objects are modeled by an ISA relationship, you should use inheritance. When they're modeled by HASA, you should use composition. A Dog is not an Animal that includes Barkable and PeeOnHydrantable, and a SpaceShuttle is not a descendant of Airplane. |
|
Just saying "use the tool appropriate to the job" dismisses the entire problem where in the real world, it isn't clear what that is.