When to Use Inheritance or Composition
来源:互联网 发布:一起走软件作弊 编辑:程序博客网 时间:2024/05/16 06:49
1 Avoid multiple inheritance at all costs, as it’s too complex to be reliable. If you’re stuck with it, then be prepared to know the class hierarchy and spend time finding where everything is coming from.避免使用多层次继承
2 Use composition to package code into modules that are used in many different unrelated places and situations.模块可用组合
3 Use inheritance only when there are clearly related reusable pieces of code that fit under a single common concept or if you have to because of something you’re using.
0 0
- When to Use Inheritance or Composition
- How to use composition and inheritance in visual c# ?
- Composition vs. Inheritance: How to Choose?
- Inheritance & Composition
- Python multiprocessing.Pool: when to use apply, apply_async or map?
- When to use Delegation, Notification, or Observation in iOS
- When to use DMU?
- When to use AtomicReference?
- 老调重弹 Composition versus Inheritance
- Inheritance VS Composition
- Favor composition over inheritance
- Inheritance vs Composition
- When to use assert() and when to use try catch?
- When to use Class.isInstance() & when to use instanceof operator
- when to use Java Beans
- msdn:when to use udp
- When to use virtual destructor?
- Bind: Address Already in Use Or How to Avoid this Error when Closing TCP Connections
- 56.使用NSURLProtocol实现UIWebView的离线缓存-转载
- 如何实现自动升级?
- IOS-笔记20(Embed Segues)
- c语言编的心形图案,有兴趣的看看
- 观察者模式
- When to Use Inheritance or Composition
- 安卓四大组件之一Activity
- Android 入门(3)
- HDU 2393 Higher Math
- 57.阐明iOS证书和provision文件
- android 隐藏滑动滚动条
- Memcached之HA架构(9)
- UESTC 360 Another LCIS(线段树 x 经典区间合并姿势)
- 用户界面之view