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. C#中属性的使用——主动调用才发挥作用

    微软对属性定义如下: “属性是这样的成员:它提供灵活的机制来读取.编写或计算某个私有字段的值. 可以像使用公共数据成员一样使用属性,但实际上它们是称作“访问器”的特殊方法. 这使得可以轻松访问数据,此 ...

  2. Win32程序框架

    // WinMsg.cpp : 定义应用程序的入口点. // #include "stdafx.h" #include <stdio.h> #include " ...

  3. Continuous Design

    Continuous Design https://www.martinfowler.com/ieeeSoftware/continuousDesign.pdf T he rising popular ...

  4. UIBezierPath基本使用

    UIBezierPath * aPath = [UIBezierPath bezierPathWithArcCenter:point radius:5 startAngle:0 endAngle:2 ...

  5. linux 删除占用文件

    清空 程序占用日志文件: cat /dev/null > log 或: echo " " > log 直接删除程序占用文件大小不生效: rm -rf log ps -e ...

  6. ue4 编辑器记录

    Matinee 编辑器 菜单:Add New Empty Group->选择要变动的Actor->菜单:Add Actor->菜单:Add Key->变更Actor属性-> ...

  7. this与回调函数

    在c++里回调函数分2种: 全局函数:不包函在类的内部 或 类内部的静态函数 类内部函数(或叫 局部函数):需要通过实例化后的对象调用的 因c++是c的一层封装,所以类似c里struct内的函数 在传 ...

  8. Python常用模块之time模块

    python中的time和datetime模块是时间方面的模块 time模块中时间表现的格式主要有三种: 1.timestamp:时间戳,时间戳表示的是从1970年1月1日00:00:00开始按秒计算 ...

  9. telnet能通但是ping不通

    以前本人以为Telnet通 ping一定也是通的, telnet能通,表示两台计算机之间建立了连接通道.理论上是能ping通的.如果不能ping通,可能的原因是对方主机关闭了ping回显,或者是对方的 ...

  10. java.io.IOException: Server returned HTTP response code: 411 for URL

    今日调用一post方式提交的http接口,此接口在测试环境ip调用时无问题,但在生产环境通过域名调用时一直报如下错误: java.io.IOException: Server returned HTT ...