Defining a Class

When the Define Class dialog is first opened, the Class sheet is displayed, to enable you to define your new class.

As the Protected option in the Access group box is reserved for future use, only public access to classes is supported; that is, selecting the Protected option button has no effect. Class access is public; that is, class instances can be created or deleted by another class by default. For details about controlling how classes implemented in your schemas are used by developers in other schemas, see "Controlling the Use of Elements in Other Schemas", in Chapter 1.

To define a class

  1. In the Name text box, specify the name of the class that you want to define. The name must be unique within the schema to which it is being added.

    The class name must start with a letter, and the first four characters should not be Jade (which is used to prefix JADE system classes). It can include numbers and underscore characters, but cannot include punctuation or spaces. The first letter of the name is converted to an uppercase character, if it is lowercase.

  2. In the class list of the Subclass of combo box, select the class of which you want your new class to be a subclass. All classes in the current schema are listed in alphabetical order, to enable you to select the required class. By default, the class selected in the Class List window of the Class Browser is displayed in the text box.

    For details about filtering the entries displayed in the list box associated with the Subclass of combo box, see "Filtering Entries in Combo Box and List Box Text", in Chapter 2.

  3. In the map file list of the Map File combo box, select the database file to which instances of the class are to be stored.

    The Map File combo box is disabled when you add a subclass to a control. All control subclasses are mapped to the _usergui.dat file, and cannot be changed.

    For details about the system map files that store persistent objects in your JADE schemas, see "System Map Files", earlier in this chapter.

    All map files in the current schema are listed in alphabetical order, to enable you to select the required file. By default, the last map file selected is displayed in the text box. (The text box is empty if it is a new schema to which no map files have yet been added.) The map file must already exist. (Define a map file by using the Add command from the MapFiles menu in the Class Maps Browser.)

  4. Select the Abstract option button in the Type group box if you do not want the class to be of Real type. By default, classes have a Real type so that an instance of a class can be created. As class instances cannot be created for abstract classes, you can use them to factor out behavior common to a number of classes; for example, the Dictionary subclass of the Collection class. (See also "Class Lifetime Options", in Chapter 1.)

    You can change the type of a dictionary subclass that is abstract, has at least one key, and has subclasses from abstract to real only if it does not have abstract methods.

    Only changes to keys are propagated to dictionary subclasses.

  5. Select the Transient option button in the Persistence group box if you do not want the default lifetime of instances of the class to be persistent.

    By default, the default lifetime of class instances is persistent. Instances of a transient class exist only during the application session; for example, the File class.

    You can create a transient instance of a persistent class and a persistent instance of a transient class. Use the Lifetime sheet to restrict creation of class instances. (For details, see "Specifying Class Lifetimes", later in this chapter.)

  6. Check the Subschema Hidden check box if you want to specify that the class is available only in the local schema. This check box is unchecked by default; that is, the class is available in subschemas. For details, see "subschemaHidden Option" under "Controlling the Use of Elements in Other Schemas", in Chapter 1.

    Classes that are subschema-hidden are not available for use in any subschemas. They cannot be referenced by subschema code, and they are not displayed in subschema Class Browsers.

  7. Check the Subschema Final check box if you want to specify that the class can be extended or reimplemented in its local schema but not in a subschema. A class that is subschema-final has no restrictions on it in its local schema but the class cannot be subclassed in subschemas.

    This option does not restrict methods and constants being added to subschema copies of the class.

    This check box is unchecked by default; that is, the class can be extended and reimplemented in subschemas. For details and an example, see "subschemaFinal Option" under "Controlling the Use of Elements in Other Schemas", in Chapter 1.

  8. Check the Final (Class cannot be subclassed) check box if you want to specify that the class cannot be subclassed (that is, it is final in the current schema) and the class is restricted in this schema and its subschemas.

    This option does not restrict methods and constants being added to subschema copies of the class.

    This check box is unchecked by default; that is, it cannot be subclassed. For details, see "final Option" under "Controlling the Use of Elements in Other Schemas", in Chapter 1.

  9. Click the Add Map File button if you want to add a new map file for the current schema. The File Dialog is then displayed, to enable you to define your new map file. For details, see "Adding or Changing a Map File", earlier in this chapter.

    When you have specified the new map file and clicked the OK button on the File Dialog, the class map file is displayed in the schema hierarchy of the Class Maps Browser and is selected in the Map File combo box on the Class sheet of the Define Class dialog.

    The map file addition is an independent update that remains defined even if you cancel the class definition.

    If the Map Files combo box is disabled, the Add Map File button is also disabled. It is disabled if the class has a predefined map file or the class has instances.

  10. Click the OK button. (Alternatively, click the Cancel button to abandon your selections or the Next button to define another class.)

If you added a subclass to a Collection class, you must then select the Membership sheet. If you added a subclass to a Dictionary class, you must then select the Keys sheet.

You can select the Lifetime sheet if you want to restrict the lifetime of instances of the class and its subclasses, the Tuning sheet if you want to tune a Collection subclass, or the Volatility sheet if you want to change the volatility of instances of the class.

If you want to enter free-format descriptive text for the class, select the Text sheet.

If a class template has been defined for all new classes in your JADE development database or for your own JADE classes, the class template is displayed below the class details in the editor pane when you click the OK button on the Define Class dialog. For details, see "Maintaining Text Templates", in Chapter 2.