3 ms·
Composition Over Inheritance – Object Oriented Programming
- collyw 13y agoRead the article, then wikipedia to see why the preference. Yes, I can see that composition can leave you a more flexible model, but at the same time inheritance could save you a fair bit of coding. And less code is less likely to have bugs (though probably composition code is fairly straight forward). I guess use each where it is appropriate. http://stackoverflow.com/questions/56860/what-is-the-liskov-substitution-principle http://stackoverflow.com/questions/56860/what-is-the-liskov-... The stack overflow answer seems to be a good guideline.