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. Shell编程(四)Shell变量

    1. 自定义变量(仅在当前shell生效) 1.1 定义变量 #!/usr/bin/bash ip=115.239.210.27 if ping -c1 $ip &>/dev/null ...

  2. MysqL_select for update锁详解

    先来举一个在某些应用场景下会出现数据不一致的例子,当然存储引擎是InnoDB(至于为什么,后面再告诉你). 电商平台常见的下单场景: 一般商品表(goods)有基本的四个字段,id(主键),goods ...

  3. GIL 全局解释器

    全局解释器锁 GIL 相当于给python解释器加了一把互斥锁 每一个进程都有一把互斥锁,所有线程必须先拿到解释器,才能执行代码, 同一进程下,所有线程并发 在 Cpython 解释器下,多个进程可以 ...

  4. Docker-01 无人值守升级 CentOS 6.x 系统内核到 3.10.x 长期支持版

    #!/bin/bash # # 无人值守升级 CentOS .x 系统内核到 3.10.x 长期支持版 # # # .检查操作系统是否为 CentOS .x # cat /etc/centos-rel ...

  5. List<string>序列化与反序列化一个小坑

    Newtonsoft序列化与反序列化有两个重载方法,带<T>和不带<T>的 如果将一个List<String>序列化为jsonStr后,再反序列化,会变成JArra ...

  6. JS定义函数

    一.定义函数的方法 (1)函数声明 (2)函数表达式 二.函数声明方法定义函数 function functionName(arg0, arg1, arg2) { // 函数体 } (1)FireFo ...

  7. 【SRM-06 D】五色战队&&【codeforces 788E】 New task

    原题链接:788E - New task Description 游行寺家里人们的发色多种多样,有基佬紫.原谅绿.少女粉.高级黑.相簿白等. 日向彼方:吾令人观其气,气成五彩,此天子气也. 琉璃:我们 ...

  8. 第26月第13天 hibernate导包

    1. https://yq.aliyun.com/ziliao/386827

  9. 15款Java程序员必备的开发工具(转)

    如果你是一名Web开发人员,那么用膝盖想也知道你的职业生涯大部分将使用Java而度过.这是一款商业级的编程语言,我们没有办法不接触它 对于Java,有两种截然不同的观点: 一种认为Java是最简单功能 ...

  10. Eclipse安装lombok及常用注解

    转自:https://blog.csdn.net/ZJDWHD/article/details/77795023 lombok的官方网址:http://projectlombok.org/ https ...