Date: 2011-01-25 03:28 am (UTC)
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.
This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

Profile

juan_gandhi: (Default)
Juan-Carlos Gandhi

June 2025

S M T W T F S
1 2345 6 7
8 9 10 11 121314
15161718 1920 21
222324252627 28
2930     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jun. 30th, 2025 04:15 am
Powered by Dreamwidth Studios