Basic Concepts
Like any object‑oriented technology, ObjAsm introduces its own terminology and fundamental concepts. Below is a clear description of these basic terms:
Ancestor Object
An ancestor object is the parent of a derived object. The derived object inherits all properties of its ancestor. Multiple derived objects can share the same ancestor. New variables and methods can be added to meet specific needs.
Constructor
A constructor is a special method used to initialize an object instance. In high‑level languages like C++, constructors are invoked automatically. In ObjAsm, an object can have multiple constructors, but the programmer is responsible for calling them. Since ObjAsm initializes object variables automatically, a constructor may not always be necessary. During standard instantiation, initial values are copied from a compile‑time template in memory.
Derived Object
A derived object inherits both data and procedures from a preceding object. A derived object can itself serve as the ancestor for further derivations, forming a hierarchy of related objects. ObjAsm supports single inheritance, meaning each derived object inherits from only one ancestor.
Destructor
A destructor is a special method called when an object instance is destroyed (using Destroy or Kill). It handles cleanup tasks such as releasing resources allocated by constructors. ObjAsm includes a default virtual destructor named Done. If resource cleanup is required, Done must be redefined. In the virtual method table (VMT), Done occupies the first slot.
Encapsulation
Encapsulation refers to grouping data and the code that operates on it within an object. Methods manipulate the encapsulated data, and restricting direct access improves maintainability and simplifies debugging.
Inheritance
Inheritance transfers members from an ancestor object to a derived object. It enables developers to enhance existing objects by modifying methods or adding new variables and procedures.
Instance
An instance is the memory allocated and used to represent a specific object in a program.
Member
A member is any component of an object, including methods, variables, or embedded objects.
Method
A method is another name for an object’s procedure. Methods can be:
Static: Resolved at compile time and cannot be changed.
Virtual: Stored in the virtual method table (VMT).
Dynamic: Stored per instance and can be changed at runtime.
Inline: Expanded in place during compilation.
Interface methods: Used for communication via COM or similar interfaces.
Methods can also be private to restrict their visibility outside their object. ObjAsm’s Dual Method Table (DMT) separates interface methods (in the Interface Method Table, IMT) from other virtual methods (in the VMT). Changes to the DMT affect all instances of a type — a behavior known as object superclassing. Meanwhile, dynamic methods stored in instance data allow per‑instance redefinition, known as object subclassing.
Object
An object combines related data and code into a single structure. It acts as a template; to use it in a program, you must create an instance. In high‑level languages like C++ or Pascal, an object corresponds to a class.
Polymorphism
Polymorphism enables an object to determine at runtime which method to execute. For example, if a base object Shape defines a Draw method and derived objects Triangle and Rectangle override it, a call to Draw on any shape instance will invoke the correct implementation.
Composition
Composition is a part‑whole relationship where one object (the part) belongs exclusively to another (the whole). The part is created and destroyed with the object. For a true composition:
The part belongs to the object.
It can belong to only one object at a time.
The object controls the part’s lifecycle.
The part is unaware of the object’s existence.
Composition enables code reuse without modeling an is‑a relationship (as in inheritance) and simplifies working with complex objects. ObjAsm implements composition using the Embed macro.
Single Inheritance
Single inheritance means building a derived object from only one ancestor. Unlike multiple inheritance supported in some high‑level languages, ObjAsm does not allow a derived object to inherit from more than one parent. Object embedding provides an alternative for managing complexity.
Method Types
Virtual Method: A method whose address is stored in the VMT and shared among all instances
Private Method: A method with restricted access, callable only from within its object.
Interface Method: A virtual method used for COM or similar interface implementations.
Dynamic Method: A per‑instance method whose address can be independently redefined.
Static Method: A method resolved at compile time; it cannot be changed and offers the fastest invocation but lacks polymorphism.
Inline Method: A method whose code is expanded at the invocation point, similar to a MASM® macro.
Last updated