|
Spec-Zone .ru
спецификации, руководства, описания, API
|
Table of Contents
Classes represent kinds of things, whether they be concrete things, graphical things, or conceptual things. And instances of classes represent specific things. For example, in JavaFX:
class Shoe {
var color : String;
var size: Number;
var style : String;
}
def rubySlipper = Shoe {
color: "red"
size: 7
style: "slipper"
}
Here the class Shoe represents a kind of thing, and the instance stored in rubySlipper is a representation of a concrete thing. Note that there are instance variables that store the state of the instance.
Whereas the class CheckBox is a kind of graphical thing:
public class CheckBox extends CustomNode, Resizable {
public var title : String;
public var visible : Boolean;
public var skin : Skin on replace oldSkin {
if (skin != null) then skin.control = this;
if (oldSkin != null) then oldSkin.control = null;
}
public function requestFocus() : Void {
if (visible) then skin.requestFocus();
}
}
It extends two other classes (CustomNode and Resizable), therefore including their instance variables and instance functions. CheckBox adds three more instance variables, including skin which has an on-replace clause to maintain a relationship between the skin and the CheckBox. It also adds an instance function requestFocus.
[To do: add a section on instance initialization (before the instance variable initialization section). Then clean up the instance variable initialization section]