PERGOLA LOGO

Class operations

Designing an OOD model requires efficient subclassing and extension methods. These methods must take into account the typology of the language. Pergola's subclassing method allows subclassing of one or more classes to a superclass, after definition and in one single operation. It also allows to subclass a set of subclasses to a subclass without interfering with the previous superclass inheritance. Subsequent extensions (immediate or deferred) of a class or a prototype with new sets of class or prototype properties and methods is a prerogative of JavaScript, one that doesn't follow a bureaucratic model. This, plus the characteristic that properties always resolve to strings, makes that JavaScript is the OOP language by excellence.

Subclassing

pergola.subclass(subClass, baseClass)

subClass is a class or an array of classes to be subclassed to baseClass. The function applies inheritance, then reassigns subClass to subClass.prototype.constructor, and defines the subClass properties baseConstructor reference to baseClass, and superClass reference to baseClass.prototype.

Add collections of properties and methods to objects, classes, and prototypes.

pergola.extend(entity, ext)

The ext object specifies the collection of properties and methods to be inherited by entity object, class, or prototype. Returns entity.

Destruction

pergola.destroy(handle, name)

This is a generic function for deleting properties and variables. It deletes the name string property of the handle object, or attempts to delete the global name variable or, if unsuccessful, it sets it to null.

Note: attempting to delete a variable or property designating a class may require calling the class's private destruction method first for freeing eventual services used by said class, before calling this generic function. Failing to do so may result in strange or unexpected behaviors –depending on the implementation– which may not necessarily throw errors. Initialized service processes may wait forever for termination, and attempting to destroy a reference (from an Undo or Key instance, for example) may throw uneasy to trace errors.