Introduction
Object orientation is a way to image real world problems to software. There are two interrelated notions:
| Class | template with a certain behavior that is used to create objects |
| Object | entity that uses the class' behavior and has an own set of state information |
A typical example for a class is a car, while your own car is a specific object.
This package contains functions to define classes and generate objects. A class may contain state information in its fields and functions that can access this state, called methods. Usually, the state is bound to a specific object generated from the class, for example the owner's name of a car, while methods are always shared by all objects derived from the same class, for example the functionality of the breaks. The combination of the state and the behavior (methods) in one object makes objects easy to use, because every object is aware of its state and a function needs not to get the state as a parameter. In order to hide information that is not be intended for external use, class members may be restricted in their usage. Once a class is defined, another class may reuse all state and behavior information from the former just by declaring it as parent. This mechanism is called inheritance. Only additional functionality must then be defined in the new class. This new functionality may replace (override) members of the ancestor class. Polymorphism assures that every object is aware of its generating class and that the appropriate functionality, possibly in a derived class relative to a method, is accessed. Altogether, we have four main issues implemented by this package:
| Abstract Data Type | state and behavior are combined |
| Encapsulation | access may be restricted |
| Inheritance | derived class automatically has the functionality of its parent |
| Polymorphism | behavior context given by object |
This package allows to inherit from a single parent class. The concept of an interface allows to handle cases in which a class or object needs to export the functionality of several classes.
During testing it may be necessary once in a while to delete all definitions of a class by means of
ClearAll[class]. This also disrupts the chain of inheritance. In many cases, it will be sufficient just to redefine a class without worrying about possible side effects. Every help section of this package assumes that no classes were defined before entering the section. With respect to automatic class and object numbers, each section starts from scratch.