Classes

Although an object is an instance of a class, it is easier to describe a Zim object first. An object is the encapsulation of attributes and behaviour.

Attributes values are stored on an Attribute Structure implemented using a form entity. State values are also stored on this structure (e.g. object modified).

Behaviour is described by methods, which are executed from a text or binary file.

A class is a template for multiple objects. In Zim, the instantiation of an object occurs when a class is assigned attributes. Only one object at a time can be instantiated. Zim does not currently support multiple instantiation.

Zim Classes can be divided into two main categories, User Interface and Business Classes.

User Interface Classes

User Interfaces (UI) Objects consists of windows, displays, forms, menus, toolbars and the behavioural code to operate these objects. UI Classes provides views of sets produced by Business Classes.

For example, the UI class zCustomerUI provides a view of the set sCustomer produced by zCustomer, a business class. There can be multiple views of the same set, for example zCustomerFormUI, which provides a view of a single record and zCustomerTableUI, which provides a view of multiple records.

There may also be other UI classes that do not provide an interface to a set, for example, a printer set-up dialog.

Business Classes

A business class derives its name from the set. For example, the set sCustomer is encapsulated by the business class zCustomer. Of course a set could be a complex object, for example, Order Header and Order Items which would be translate to the class zOrder.

Attributes and behaviour

To create a class the attributes and behaviour must be described. An attribute structure is defined in the object dictionary for the purpose of storing attribute values - state information and parameters. The attribute structure name is derived from the root class name prefixed with a lowercase 'a'. For example, the class zCustomer has an attribute structure aCustomer.

The behaviour is described using the Zim language as before. Previously, behaviour was described in procedures and local procedures, behaviour is now described in methods.

Creating a Class

A class in Zim consists of a document and an attribute structure defined in the Object Dictionary. The class declaration is defined in the document text file.

A class declaration:

class zCustomer(viMethod, viSelf) endClass

As you can see PROCEDURE and ENDPROCEDURE are no longer used. These have been replaced with two new keywords CLASS and ENDCLASS. viMethod and viSelf are explained later in this document.

An attribute structure is defined once a class has been created. Attributes store an instance of the data object.

The attribute structure for zCustomer, aCustomer, might have the following fields:

 

FieldName

Type

Length

Description

ID

Int

10

Unique Identifier.

FirstName

Alpha

40

Class Attribute.

LastName

Alpha 50

 

Class Attribute.

Salutation

Alpha 10

 

Class Attribute.

StreetAddress

Alpha

80

Class Attribute.

City

Alpha 50

 

Class Attribute.

Country

Alpha 50

 

Class Attribute.

pMethod

Alpha 256

 

The method passed to this class. This parameter is a mandatory attribute for all structures.