1 / 25

CAR 构件技术 及 ELASTOS 操作系统

CAR 构件技术 及 ELASTOS 操作系统. 上海科泰华捷科技有限公司 2014.8. 题外话. 谈点理论 , 谈 点技术 理论 来源于 朴素的想法和逻辑推理 理论与 实现 间 的差距. 主要内容. CAR 构件技术 技术要点 主要功能 演进方向. 主要 内容. Elastos 操作系统 系统架构 与 Android 的关系 主要特点 演进方向. CAR 构件技术. 技术要点 主要功能 演进方向. CAR 技术要点. 面向接口编程 C++ 扩展反射. 面向接口编程. 内聚度与耦合度 ( 软件度量 ) 高内聚 低耦合

imani-key
Download Presentation

CAR 构件技术 及 ELASTOS 操作系统

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CAR构件技术及ELASTOS操作系统 上海科泰华捷科技有限公司 2014.8

  2. 题外话 • 谈点理论,谈点技术 • 理论来源于朴素的想法和逻辑推理 • 理论与实现间的差距

  3. 主要内容 • CAR构件技术 • 技术要点 • 主要功能 • 演进方向

  4. 主要内容 • Elastos操作系统 • 系统架构 • 与Android的关系 • 主要特点 • 演进方向

  5. CAR构件技术 • 技术要点 • 主要功能 • 演进方向

  6. CAR技术要点 • 面向接口编程 • C++扩展反射

  7. 面向接口编程 • 内聚度与耦合度(软件度量) • 高内聚 • 低耦合 • 模块化(独立维护与升级) • 调用方与具体实现解耦 • 设计模式中使用 • 类型(或结构)抽象 • 模式与实现解耦 • Listener模式

  8. 面向接口编程 • 思考 • 为何是面向接口?面向类(或抽象类)是否可行? • 接口是否可以包含属性?

  9. 面向接口编程 • 使用方与实现方的契约(Contract) • 已有契约任何时候都必须有效(不能改变) • 增加新契约不影响现有约定 • 与语言的具体实现相关 • 对象模型 • 成员变量访问和方法调用的解析方式 • 编译时绑定 • 运行时解析 • C++ • Java

  10. 面向接口编程 • C++ • 普通函数与虚函数 • 普通函数:静态绑定(编译时绑定,暴露了对象实现)不符合 • 虚函数:动态绑定(运行时解析,隐藏对象实现)符合 • 成员变量 • 静态成员变量:不占用对象内存空间 符合 • 普通成员变量:占用对象内存空间,改变对象布局 不符合 • 接口与类 • 接口(抽象类):纯虚函数+静态成员变量符合 • 类:函数+成员变量(改变对象布局) 不符合

  11. 面向接口编程 • Java • 对象模型 • JVM Spec不做具体的规定 • In some of Oracle’s implementations of the Java Virtual Machine, a reference to a class instance is a pointer to a handle that is itself a pair of pointers: • one to a table containing the methods of the object and a pointer to the Class object that represents the type of the object, • the other to the memory allocated from the heap for the object data. • *The Java Virtual Machine Specification, Java SE 7 Edition (Java Series) [Tim Lindholm, Frank Yellin, GiladBracha, Alex Buckley]

  12. 面向接口编程 • Java • 成员变量访问 • 运行时解析成员变量(非编译时绑定, C++) • getfield • http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.getfield // 128: aload_0 // 129: getfield93 com/google/android/location/internal/server/ServiceThread:contextLandroid/content/Context;

  13. 面向接口编程 • Java • 方法调用 • 运行时解析成员变量(非编译时绑定, C++) • invokeinterface, invokevirtual • http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.invokeinterface • http://docs.oracle.com/javase/specs/jvms/se7/html/jvms-6.html#jvms-6.5.invokevirtual

  14. 面向接口编程 • Java • 接口(interface) • 成员变量是static, final和public 符合 • 方法是abstract和public 符合 • 类 不符合 • OSGI • The Dynamic Module System for Java • http://www.osgi.org/Main/HomePage

  15. 面向接口编程 • 接口升级 • 不能改变已有的方法以及它们的顺序 • 从尾部增加方法 • 不能改变接口ID

  16. C++扩展反射 • 反射:描述以及操纵程序本身 • 程序设计语言 • 反射

  17. 程序设计语言 • 范型(Paradigm) • 函数式语言(functional language) • Lisp, Scheme, Haskell • λ演算(lambda calculus):替换与归约 • 函数也可作为参数(first class object) • 绑定(binding)与赋值(assign) • 绑定后值不再改变,无副作用(side effect) • 赋值后值可以改变,有副作用 • 副作用:影响计算顺序(违背函数的性质) • 引入单子(monad) • 抽象为多个函数,通过函数传递(cps, Continuation Programming Style)确定计算顺序

  18. 程序设计语言 • 范型(Paradigm) • 结构化语言(structural language) • C, Pascal • 面向对象语言(object-oriented language) • C++, Java, Smalltalk, Ruby

  19. 面向对象语言 • 静态类型与动态类型 • 静态类型(static typing): C++, Java • String name; • 动态类型(dynamic typing): Smalltalk, JavaScript • name := String new asValue. • 基于类与基于原型 • 基于类(Class-based): C++, Java, Smalltalk • 基于原型(Prototype-based): Self, JavaScript

  20. 面向对象语言 • 动态类型语言 • 对象模型 • 方法调用 • 运行时解析

  21. 面向对象语言 • 动态类型 • 优点 • 支持参数化多态(Parametric polymorphism) • 无需模板(template) • 例如: AutoPtr<T> • 缺点 • 不支持静态类型检测 • 类型错误需运行时才能发现 • 例如: str := objtoString.

  22. 面向对象语言 • 基于类(Class-based) • 有类(Class)和对象(Object) • 任何对象都是类的实例 • 通过类间的继承实现代码重用 • 例如: C++, Java, Smalltalk

  23. 面向对象语言 • 基于原型(Prototype-based) • 只有对象(Object),没有类(Class) • 任何对象的产生是通过克隆另一个对象(称为原型),然后初始化自己 • 通过对象间的代理(delegation)实现代码重用 • 例如: Self, JavaScript

  24. Ungar, Smith: SELF The Power of Simplicity, Journal of Lisp and Symbolic Computation, 4/1991

  25. 面向对象语言 • Alan C. Kay’s principle (2003 Turing Award) • Everything is an object • Objects communicate by sending and receiving messages (in terms of objects) • Objects have their own memory (in terms of objects) • Every object is an instance of a class (which must be an object) • The class holds the shared behavior for its instances (in term of objects in a program list) • To eval a program list, control is passed to the first object and the remainder is treated as its message * Kay A C. The Early History of Smalltalk[J]. ACM SIGPLAN Notices, 1993, 28(3): 69-95.

More Related