I agree. Most of the time I use composition instead of imlpementation inheritance. Composition gives us better testability and control (e.g., two "super" objects can share the same "sub" object, which is impossible with inheritance).
Most inheritance attempts die when asked "can X have more than one Y". Can a car have more than one steering wheel? Well, yeah, why not. It would be a weird car, but it is quite possible. So, car is not a subclass of steering wheel.
There are, of course, other tests, but this one weeds off the vast majority of inheritance candidates.
no subject
Date: 2011-01-25 03:28 am (UTC)Most inheritance attempts die when asked "can X have more than one Y". Can a car have more than one steering wheel? Well, yeah, why not. It would be a weird car, but it is quite possible. So, car is not a subclass of steering wheel.
There are, of course, other tests, but this one weeds off the vast majority of inheritance candidates.