Liskov Principle: if S is a subtype of Type T, then any objects of type T may be repalced by objects of type S without altering any of the properties of T;
that is, if B inherits from A, then B should be a A!!!
usaully we adopt inheritance for two reason:
1) interface (for polymorphism)
2) implementation (for code reuse)
if it's for implementtation, coposition is good enough for it;
as used in most design patten, we commenly use two layers of inheritance, interface and its implementation.
with good design, we seldom more than 3 or 4 layers

how to avoid inheritance abuse的更多相关文章

  1. 10 Tips for Writing Better Code (阅读理解)

    出发点 http://www.tuicool.com/articles/A7VrE33 阅读中文版本<编写质优代码的十个技巧>,对于我编码十年的经验,也有相同感受, 太多的坑趟过,太多的经 ...

  2. 【8.0.0_r4】AMS分析(十七)(ActivityManagerService.java下)

    代码位于frameworks/base/services/core/java/com/android/server/am/,一共有七十个文件. Java源码位于package com.android. ...

  3. Effective Java 16 Favor composition over inheritance

    Inheritance disadvantage Unlike method invocation, inheritance violates encapsulation. Since you don ...

  4. Think Python - Chapter 18 - Inheritance

    In this chapter I present classes to represent playing cards, decks of cards, and poker hands.If you ...

  5. [转载]Spring Bean Configuration Inheritance

    转自: http://www.mkyong.com/spring/spring-bean-configuration-inheritance/ In Spring, the inheritance i ...

  6. Spring bean configuration inheritance

    In Spring, the inheritance is supported in bean configuration for a bean to share common values, pro ...

  7. Classical Inheritance in JavaScript

    JavaScript is a class-free, object-oriented language, and as such, it uses prototypal inheritance in ...

  8. Memory Layout for Multiple and Virtual Inheritance

    Memory Layout for Multiple and Virtual Inheritance(By Edsko de Vries, January 2006)Warning. This art ...

  9. <Effective C++>读书摘要--Inheritance and Object-Oriented Design<二>

    <Item 36> Never redefine an inherited non-virtual function 1.如下代码通过不同指针调用同一个对象的同一个函数会产生不同的行为Th ...

随机推荐

  1. 转换流InputStreamReader & OutputStreamWriter

    转换流InputStreamReader & OutputStreamWriter 比如当使用FileReader读取文件时,可以读取IDE默认的UTF-8编码的文件,但是当有一个文件是GBK ...

  2. 四.HashSet原理及实现学习总结

    在上一篇博文(HashMap原理及实现学习总结)详细总结了HashMap的实现过程,对于HashSet而言,它是基于HashMap来实现的,底层采用HashMap来保存元素.所以如果对HashMap比 ...

  3. js动态修改Easyui元素不生效,EasyUI动态渲染解析解决方案

    easyui的渲染是在在网页加载完成后,相当于在$(document).ready()事件中,对整个网页进行了一次扫描,发现某个input标签含有easyui的属性,就在相应的地方进行ui的修改.因此 ...

  4. nginx: [error] CreateFile() "E:\nginx\nginx-1.9.3/logs/nginx.pid" failed

    nginx: [error] CreateFile() "E:\nginx\nginx-1.9.3/logs/nginx.pid" failed nginx: [error] Op ...

  5. Linux之Ubuntu下DSL拨号上网

    可视化桌面配置方法 1.编辑连接 2.选择 增加 3.选择 DSL 4.选择 新建连接[cmcc@gx属于移动校园用户的ISP指定后缀] 6.OK 当然,还有其他拨号上网的办法: [Linux/Ubu ...

  6. 一个简单至极的PHP缓存类代码

    https://www.jb51.net/article/73836.htm 直接看代码吧!使用说明:1.实例化$cache = new Cache(); 2.设置缓存时间和缓存目录$cache = ...

  7. cookie, session, token 是什么 以及相应的安全考量

    Cookie cookie 最常见的是用来保存一些账号信息,比如下图里的 记住账号 就是记录到了cookie里面 cookie 更主要的是针对和server通信的,我们知道http 是无状态的,那如果 ...

  8. Linux/Windows双系统引导修复

    安装双系统建议先安装windows,然后在安装Linux,使用Linux(grub2)引导双系统 如果重新安装了windows,则无法引导进入linux,需要修复引导 在windows下安装easyB ...

  9. xtrabackup 在线主从搭建

    因为意外导致某个MySQL的从服务器宕机,且不可修复,因为是业务数据库,不能停机和锁表进行从库的搭建,所以考虑了使用xtrabackup 进行在线主从搭建. 一.数据库环境 注意:  主从搭建主库一定 ...

  10. DEA和模糊综合评价

    DEA(包络分析) 1.概念 利用多项投入指标和产出指标,利用线性规划的方法,对具有可比性的同类型单位进行有效性评价的一种数量分析方法.以效率的概念作为加总模式,效率等于总产出除以总投入,并以效率最大 ...