qooxdoo--面向对象介绍

原文: http://qooxdoo.org/documentation/0.8/oo_introduction

Introduction to Object Orientation
面向对象介绍

qooxdoo allows you to easily leverage many key concepts of object-oriented programming without bothering about limited native support in JavaScript.
qooxdoo让你很容易的利用许多面向对象编程的关键概念而不用为js有限的原生支持而烦恼

The main actors of qooxdoo OO are:

*
Classes
*
Interfaces
*
Mixins

When trying to get a grip of the framework code, you should probably understand all those three concepts. As a regular application developer you often get by just knowing how to use classes.   
当尝试了解框架代码时,你可能会不理解这三个概念,但作为一个常规应用程序的开发者你通常仅需要知道如何使用这些类。

Classes

A “class” is a central concept in most object-oriented languages, and as a programmer you are certainly familiar with it. qooxdoo supports a “closed form” of class declaration, i.e. the entire declaration is provided within a qx.Class.define(name, config) statement, where name is the fully-qualified class name, and config is a configuration map with various keys (or “sections”).
"类"在面向对象的语言里是一个核心概念,作为一个程序员你当然非常熟悉,qooxdoo支持一种"关闭形式"的类声明 ,即所有声明都由 qx.Class.define(name,config)来提供,其中参数name是完全限定类名(类名包含其完整命名空间),config是一个具有多个可选key的配置表(或者称为配置节点)

There are several types of classes available, which are specified by the type key within the config map:

*
regular class:常规类
May contain class variables/methods (in a statics section) and instance variables/methods (in a members section). An instance of the class can be created using the new keyword, so a constructor needs to be given in construct.
*
static class:静态类
Only contains class variables and class methods. Often a helper or utility class. Use type : “static”.
*
abstract class:抽象类
Does not allow an instance to be created. Typically classes derive from it and provide concrete implementations. type is abstract.
*
singleton:单例类
Not more than a single instance of the class may exists at any time. A static method getInstance() returns the instance. Use type : “singleton”.

Interfaces

qooxdoo’s interfaces are similar to the ones in Java. Similar to the declaration of class they are created by qx.Interface.define(name, config). They specify an “interface” (typically a set of empty methods), that classes must implement.
qooxdoo的接口和java中的相似, 相似之处在于声明(qooxdoo中由qx.Interfaces.define(name, config)来声明class的interface)。它们指定一个接口(由空方法组成的集合),该类就必须实现

Mixins

Mixins are a very practical concept that not all programming languages provide. Unlike interfaces, which require a class to provide concrete implementations to fulfill the interface contract, mixins do include code. This code needs to be generic, if it is “mixed into” different existing classes. Mixins usually cover only a single aspect of functionality and therefore tend to be small. They are declared by qx.Mixin.define(name, config).
Mixins是一个非常有用的概念,但不是所有语言都支持。不同于接口需要类为接口的契约提供具体的实现,Mixins包含代码,如果这些代码被"mixed into"到不同的已存在的类,它们需要一般化(并入Mixin的类)。
Mixins通常仅能覆盖某一方面功能,因此趋于小巧,它们由qx.Mixin.define(name, config)定义。

Inheritance

Like most programming languages qooxdoo only supports single-inheritance for classes, not multiple-inheritance, i.e. a class can only derive directly from a single super class. This is easily modeled by the extend key in the class declaration map.
和大多数语言一样,qooxdoo仅支持类的单继承,而非多继承,即

Since a class may implement/include one or many interfaces/mixins, which themselves can extend others, some advanced forms of multiple-inheritance could be realized.
具有可继承性的类可以 实现或包含 一个或更多 接口或mixins 来达到多继承的效果 。

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值