zoukankan      html  css  js  c++  java
  • 1.6 面向对象的核心特征

    封装Encapsulation:

    is the process of hiding the implementation details of an object隐藏了对象的实现细节

    the internal state in usually not accessible by other objects内部的状态不为其他对象所访问

    the only access to manipulate the object data is through its interface 对象的数据只能通过接口访问

    继承 Inheritance

    the basic principle is simple 

    多态 Polymorphic

    when one class inherits from another ,then polymorphism allows a subclass to stand in for the superclass 当一个类从另一个类继承而来,多态使得子类可以代替父类

    the sender of astimulus doesn't need to know the recdiver's class 消息发送方不需要知道消息接收方属于哪个子类

    different receivers can interpret the message in their own way 同一类族的接收者可以按照自己的方式处理消息

    使用指向父类的指针或引用,能够调用子类的对象这是设计模式的核心基础

    聚合/组合 Aggregation/composition整体和部分的关系

    inheritance继承,飞机是一种交通工具,is a

    aggregation聚合 交通工具中由飞机 has a

    聚合 a contains b,b contains c ,a contains c 传递性

    组合整体控制部分的生命 树死了,树叶也死了

    聚合飞机毁了,其他交通工具还在

    接口/实现 interface/implementation

    抽象 Abstraction

    h

  • 相关阅读:
    JS中的this
    VS下遇到未能加载文件或程序集 错误
    观察者模式实现INotifyPropertyChanged
    看书不仔细的下场
    Android 解析XML
    杂想
    Android 对话框用法
    Android之AlertDialog.Builder详解
    Android:开机自启动并接收推送消息
    Clojure:通过ZeroMQ推送消息
  • 原文地址:https://www.cnblogs.com/mayZhou/p/10293967.html
Copyright © 2011-2022 走看看