Inheritance Learning Note

好几天没来学习了,昨晚把继承的又整理了一下。想把整理后的东西发到hexo博客上来,却发现命令行又失效了。前几天明明是好的,这几天又没有进行任何操作,网上搜了一下也没有招到合适的解决办法,无奈只能重装了。小白就是要折腾,下面贴上继承的第一个学习笔记
How to design the inheritance tree
1.Look for objects that have common attributions and behaviors.
2.Design a class that represents the common state and behavior.
3.Decide if a subclass needs behaviors(method implementations) that are specific to that particular subclass type.
4.Look for more opportunities to use abstraction, by finding two or more subclass that might need common behavior.
4 designing principles
1.DO use inheritance when one class is 大专栏 Inheritance Learning Notea more specific type of a superclass .
2.DO consider inheritance when you have behavior(implemented code) that should be shared among multiple classes of the same general type.
3.DO NOT use inheritance just so that you can reuse code from another class, if the relationship between the superclass and subclass violate either of the above two rules.
4.DO NOT use inheritance if the subclass and superclass do not pass the IS-A test.
Rules for overriding
The method are the contract
1.Arguments must be the same, and return types must be compatible.
2.The method can’t be less accessible.
Rules for overloading
1.The return types can be different.
2.you can’t change ONLY the return type.
3.You can vary the access levels in any direction.
坚持
Runbo
Inheritance Learning Note的更多相关文章
- Learning note for Binding and validation
Summary of my learning note for WPF Binding Binding to DataSet. when we want to add new record, we s ...
- Learning Note: SQL Server VS Oracle–Database architecture
http://www.sqlpanda.com/2013/07/learning-note-sql-server-vs.html This is my learning note base on t ...
- Course Machine Learning Note
Machine Learning Note Introduction Introduction What is Machine Learning? Two definitions of Machine ...
- shell learning note
shell learning note MAIN="/usr/local/" # 变量大写 STATUS="$MAIN/status" # 美元符加字符串是 ...
- 2014/09/30 Learning Note
Vbird Linux: Vim Learning: http://linux.vbird.org/linux_basic/0310vi.php Bash Shell: http://linux.vb ...
- [Angular2] @Ngrx/store and @Ngrx/effects learning note
Just sharing the learning experience related to @ngrx/store and @ngrx/effects. In my personal opinio ...
- Machine Learning Note Phase 1( Done!)
Machine Learning 这是第一份机器学习笔记,创建于2019年7月26日,完成于2019年8月2日. 该笔记包括如下部分: 引言(Introduction) 单变量线性回归(Linear ...
- Machine Learning Note
[Andrew Ng NIPS2016演讲]<Nuts and Bolts of Applying Deep Learning (Andrew Ng) 中文详解:https://mp.weixi ...
- Java: some learning note for Java calssloader and Servlet
1. Java Classloader 链接: https://en.wikipedia.org/wiki/Java_Classloader 摘要: The Java Classloader is a ...
随机推荐
- 架构之道(5) - APP和Web的后台架构
当一个项目,同时需要Web.手机H5.Android,三平台同时可以测览,那就需要很简洁而有力的架构. 而我这就经历了这麽一个项目,先开发网站,然后是手机H5,最后是Android. 自信男人,无须多 ...
- Ioc和依赖注入
转自https://www.cnblogs.com/zhangzonghua/p/8540701.html 1.IOC 是什么 IOC- Inversion of Control , 即“控制反转” ...
- 拾起HTML+CSS的一天
今天在w3school看了下HTML5和CSS3的新特性. 本来觉得自己对CSS方面基础还挺有把握的,就之前自学都是跳过这个模块的,但经过昨天会友的面试,感觉自己好像太忽视基础了,很多基本的东西很模糊 ...
- 微服务监控druid sql
参考该文档 保存druid的监控记录 把日志保存的关系数据数据库(mysql,oracle等) 或者nosql数据库(redis,芒果db等) 保存的时候可以增加微服务名称标识好知道是哪个微服务的sq ...
- The website is API(2)
一.Beautifu Soup库 from bs4 import BeautifulSoup soup = BeautifulSoup(demo,"html.parser") Ta ...
- 吴裕雄--天生自然python学习笔记:python 用 Open CV抓取脸部图形及保存
将面部的范围识别出来后,可以对识别出来的部分进行抓取.抓取一张图片中 的部分图形是通过 pillow 包中的 crop 方法来实现的 我们首先学习用 pillow 包来读取图片文件,语法为: 例如,打 ...
- day42-进程池
#进程池Pool:apply apply_async-close-join-get map callback #1.进程池Pool:执行下面代码发现任务012先执行,345后执行,因为进程池只有3个进 ...
- logstash nested内嵌字段 field protobuf解码 codec 的解决办法
logstash nested内嵌字段 field protobuf解码 codec 的解决办法 主要需求 logstash-codec 下https://www.elastic.co/guide/e ...
- python中使用自定义类实例作为字典的key
python中dict类型的key值要求是不可变类型,通常来说,我们一般采用int或者str类型来作为字典的key,但是在某些场景中,会造成一定的麻烦. 如我们有一个处理http Request的规则 ...
- [LC] 437. Path Sum III
You are given a binary tree in which each node contains an integer value. Find the number of paths t ...