top | item 7488891

Composition Over Inheritance – Object Oriented Programming

4 points| shintoist | 12 years ago |variadic.me

1 comment

order

collyw|12 years ago

Read 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-...

The stack overflow answer seems to be a good guideline.