Object Oriented Programming With LotusScript Added by ~Dexter Eljipy on March 15, 2010 | Version 1
|
Describes how Opbject oriented Programming can be applied to LotusScript
|
Classes - One of the key principals of Object Oriented Programming is the use of classes to encapuslate data objects.
- Once defined, a class should facilitate all access to the object via properties and the manipulation of that object via methods.
Class Names Class names must be unique across all LotusScript code that is references within a single module. This includes all "Use " statements and and "Use" statements contained in those LotusScripty libararies. Class names are not case sensitive. e.g. having defined a class Employee it is not possible to craete a second class callled employee and it is possible to refer to the class using EMPLOYEE.
Constructor - Each class can have a constructor denoted by Sub New
- When a class extends another class the constructors for each class are invoked starting with the based class and moving outwards.
- Unlike some programming languages, the constructor cannot be overloaded with differing number of parameters or different Types for each paremater. One way around this limitation is to provide a single parameter to the constructor of type Variant and then add logic to the constructor that tests the Type of the parameter.
Class Destructor - Each class can have a destructor denoted by Sub Delete
- When a class extends another class the destructors for each class are invoked starting with the top class moving backwards. This is the opposite order to Constructors.
Class Extension - It is possible to extend a base class using syntax Class Newclass As Baseclass
- All Properties and Methods (including constructor and destructor) are carried forward from the base class.
- The new class can replace (override) a property or method defined in its base class. The new property/method must have the exact same signature for parameters as the underlying property/method.
- When a property/method is overriden, the property/method in the base class is not invoked (Exception: Constructor and Destructor)
- To invoke the method in a base class use the syntax Baseclass..method.
Properties - It is standard practice to expose public methods using the Property Get and Property Set statements. Each property will typically be paired with a Private internal variable corresponding to the Public property.
Private iServerName As String Property Get ServerName? As String ServerName?$ = iServerName$ End Property Property Set Servername As String iServername$ = ServerName?$ End Property
- Whilst it is possible to define properties via Public variables, this is not favoured in tradition OOP.
Events - It is possible to trap events from Notes UI classes in any class that extends these classes using the Syntax On Event eventName From Notesclass Call handlername
- It is recommended the event handler be assigned the name OnEventname
e.g. On Event PostOpen? from NotesDocument Call OnPostOpen? |