TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Composition Over Inheritance – Object Oriented Programming

4 点作者 shintoist大约 11 年前

1 comment

collyw大约 11 年前
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.<p><a href="http://stackoverflow.com/questions/56860/what-is-the-liskov-substitution-principle" rel="nofollow">http:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;56860&#x2F;what-is-the-liskov-...</a><p>The stack overflow answer seems to be a good guideline.