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. SSM框架中spring的XML文件配置

    <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w ...

  2. while应用和函数学习

    # ******************************练习****************************# 在控制台中获取两个整数,作为循环开始和结束的点'''a = int(in ...

  3. Tornado基本应用

    Tornado简介 Tornado有自己的socket(异步非阻塞,原生支持WebSocket),Django没有. Tornado的模板语言更接近Python风格,比Django要好理解. Demo ...

  4. Retrofit GreenDao开发中遇到的坑

    持续更新中1.使用@FormUrlEncoded的话,服务端需要使用Request.Form,如果不使用@FormUrlEncoded本地需要由 @FieldMap Map<String, Ob ...

  5. Rootkit介绍

    Rootkit 是一种特殊类型的 malware(恶意软件). Rootkit 之所以特殊是因为您不知道它们在做什么事情.Rootkit 基本上是无法检测到的,而且几乎不能删除它们. 虽然检测工具在不 ...

  6. 虚拟环境jupyter notebook使用【virtualenv环境】

    一.进入虚拟环境 source tf1/bin/activate 二.安装 IPykernel python2版本: pip install ipykernel python3版本: pip3 ins ...

  7. scrapy框架的每个模块的用途

    ## 一.scrapy框架的每个模块的用途 1.spiders: 自定义爬虫 定义允许爬取的范围 定义开始爬取的url parse:一定要重写 start_request:一般不需要重写,可以通过重写 ...

  8. codeforces706E

    好精妙的一道题啊 传送门:here 大致题意:有一个$ n*m$的矩阵,q次询问每次交换给定两个无交矩阵的对应元素,求操作后的最终矩阵? 数据范围:$ n,m<=1000, q<=1000 ...

  9. Spring MVC 注解相关

    // required=false表示不传的话,会给参数赋值为null,required=true就是必须要有 @ResponseBody @RequestMapping("testRequ ...

  10. Python概念(八)字符串格式化:%和.format

    https://www.cnblogs.com/nulige/p/6115793.html