LOTUSSCRIPT LANGUAGE


Overview of user-defined data types and classes
User-defined classes are common to object-oriented programming and are used to represent objects whose data can be protected, initialized, and accessed by a specific set of procedures.

User-defined data types and classes can both contain multiple variables of different data types. Unlike user-defined data types, classes can also contain procedures (properties and methods) that operate on those variables.

You can extend a class but not a user-defined data type. That is, you can derive new classes (called derived classes) from an existing class (called a base class), where the derived classes inherit from the existing (base) class. For example, you could extend an Employee class by creating a FullEmployee class to represent full-time employees and a Contractor class to represent temporary employees. Both the FullEmployee class and the Contractor class share common data (ID, lastName, firstName, payCheck) provided by the Employee class.

Demonstrates the Employee base class and the FullEmployee/Contractor derived classes

Another important difference between user-defined data types and classes is that a variable of a user-defined data type holds actual data, while a class’s object reference variable points to an object’s data stored in memory. For example, Person1 and Person2 can be object reference variables that point to the same CheckingAccount object. This flexibility allows two different people to access the same checking account.

Demonstrates the Person 1 & 2 object reference variables of the CheckingAccount object

In general, you create a user-defined data type for operations that don’t need properties and methods. For example, you might create a data type named Coordinates that contains member X and Y coordinates in order to perform simple file read/write operations. In most other cases, you will want to create classes.

See Also