ObjAsm
Search…
⌃K

Basic Concepts

Like other technologies, OOP comes with its own concepts and terminology. You will find many of them in the following paragraphs:

Ancestor object

An object that is the parent of a derived object. The latter inherits all properties of his ancestor. Multiple derived objects can inherit the properties of a common ancestor object. In order to meet their own needs, new specific variables and methods can be added to these objects.

Constructor

A special method that initializes an object instance. In some HLLs like C++, constructors are called automatically. In ObjAsm, an object can have more than one constructor and it is the coder responsibility to call it. Because ObjAsm initializes object variables automatically, a constructor may not be required. During regular instantiation, the initial values are copied from a template in memory defined at compile time. More on this topic later (see lifecycle).

Derived object

An object that inherits the members (variables and code) of a predecessor object. A derived object can be used as the ancestor from which other objects can be derived. The chain of ancestors and derived objects in an OO program creates a hierarchy of related objects.
Using ObjAsm, a derived object inherits the properties of only one ancestor. This is called “single inheritance”. See embedding objects.

Destructor

A special method is called when an object instance is to be destroyed using the Destroy or Kill macros. This method is responsible for the entire housekeeping, such as the deallocation of the resources usually committed by the constructor.
In ObjAsm there is only one automatic destructor called Done. It must be redefined for every object that needs to handle situations such as the release of particular resources. Done is virtual method, whose address is located in the first placeholder in the virtual method table (VMT).

Encapsulation

The process of linking data and code in an object. A method usually performs some operations on the encapsulated data. Encapsulation limits the use of this data to a predefined set of methods, which simplifies debugging, maintenance and revision.

Inheritance

The process of transferring members of an ancestor to a derived object. By using inheritance, you can quickly improve existing objects by simply modifying existing methods or adding new variables and methods that enrich them.

Instance

Memory used to implement an object.

Member

Any component of an object. Members are methods, variables and other embedded objects.

Method

Another term for an object procedure. A method can be static, virtual, dynamic, inline or form part of an interface.
Methods can be private to limit their visibility (scope) from other objects or modules.
Interface methods are virtual methods used to communicate using the COM technology. The special design of the method jump table preserves the structure of COM interfaces separating them from the rest of the virtual methods. The whole jump table is called Dual Method Table (DMT). COM methods build up the Interface Method Table (IMT) and the remaining regular virtual methods the Virtual Method Table (VMT). Since all object instances of the same type share the same DMT, a change of a method address will affect all instances. This is called object superclassing.
While virtual and interface method addresses are stored in the DMT, a dynamic method address is stored as an instance data. This is completely transparent to the coder and allows redefinition of these type of methods at runtime independently on a per instance basis. This is called object subclassing.

Object

A structure that relates data and code. It is important to understand that an object is merely a source code description of related data and code. To use an object in a program, you must create an instance of it. The object concept is equivalent to a class in some HLLs like C++ or Pascal.

Polymorphism

The process by which an object can determine the method to execute or the variable to take.
For example, you have two objects, “Triangle” and “Rectangle” derived from a common ancestor called “Shape” and this ancestor defines a Draw method. This method is redefined on each of the derived objects to render the corresponding shape. Now it is possible to call the draw method regardless of the object type. Ty simply calling the “Shape” Draw method of any of the derived object instances, the correct shape rendering procedure is invoked.
The same concept applies to all object members.

Composition

The composition relationship is a part-whole relationship where a part can only be a part of one object at a time. This means that the part is created when the object is created and destroyed when the object is destroyed. To qualify as a composition, the object and a part must have the following relationship
  1. 1.
    The part (member) is part of the object (class).
  2. 2.
    The part (member) can only belong to one object (class).
  3. 3.
    The part (member) has its existence managed by the object (class).
  4. 4.
    The part (member) does not know about the existence of the object (class).
A composition may avoid creating some parts until they are needed.
Using object composition can provide the following benefits:
  1. 1.
    Reuse existing code: object composition allows to reuse of the existing code without a need to model an is-a relationship as usually done in inheritance.
  2. 2.
    Change in implementation of the class used in the composition without requiring external clients: composition also allows to make code easier to change and adapt if necessary. The internal classes can be changed without any side effects and changes can be handled internally.
  3. 3.
    Complex Objects: composition makes handling of complex objects much easier than using multiple inheritance.
ObjAsm implements composition using the Embed macro.Single inheritance

Single inheritance

The technique of building a derived object from a single ancestor object. Some HLLs support the inheritance of more than one ancestor object. This is called multiple inheritance and is not supported by ObjAsm.
ObjAsm supports embedding objects, which makes handling complex objects much easier than multiple inheritance.

Virtual method

An object method whose address is defined at compile time and stored in the virtual method table (VMT). This method address is shared with all instances of the same type.

Private method

A method with limited scope that restricts its invocation from within methods of the same object.

Interface method

A virtual method that can be used to implement COM or similar interfaces.

Dynamic method

A method whose address is stored as an object variable and can be redefined for each instance independently.

Static method

A method whose address is resolved at compile time and cannot be changed. The method address is hardcoded. The call of as static method is the fastest invocation type at the cost of polymorphism.

Inline method

A method whose code is expanded in place of the invocation. It can be thought as a MASM® macro that expands where the invocation is done.