Developers Manual 1.20

1. Defining the Object Model

The first step in creating a ReStore application is to define your data model - the structure of your model classes. This allows ReStore to automatically create database rows from your objects, and also to create the actual database table in which those rows will exist.

Defining the structure of a class is done with the class method addClassDefinitionTo:. This method simply lists the name of each instance variable in the class, and defines the type of object held in that instance variable. The 'type' of object will be either a class, a parameterised class, or a collection. These different types are highlighted in the following example from the Entertainment Shop class Order:

addClassDefinitionTo: aTable

aTable
        define:
#date as: Date;                            
        define:
#customer as: Customer;               
        define:
#items as: (OrderedCollection of: OrderItem);
        define:
#isAwaitingStock as: Boolean;
        define:
#totalPrice as: (ScaledDecimal withPrecision: 8 scale: 2);
        define:
#despatchDate as: Date

 




"Class"
"Class"
"Collection"
"Class"
"Parameterised Class"
"Class"

1. Defining Classes

2000-2003 Solutions Software Ltd.

Home | Index | Next