zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    APP测试
    Pycharm+Rf框架的自动化
    Robot Framework框架做UI自动化测试的介绍
    python-元组
    python-list一些用法
    [Python]之列表list
    接口测试用例(安全测试)
    cookie与session机制
    接口测试与网络通讯原理
    简单常用的SQL命令
  • 原文地址:https://www.cnblogs.com/lijianming180/p/12230906.html
Copyright © 2011-2022 走看看