t3x.org / t3x / t3x-manual / 291.html
 
T3X - A Minimum Procedural Language
Version 8.1.5, Online Edition
Copyright(C) 1996-2004
Nils M Holm
 
Previous:
2.9 The T3X Object Model
TOC | Index | Back Next:
2.9.2 Classes

2.9.1 Object Oriented Programming

What is the object oriented programming (OOP) paradigm anyway? The term 'object oriented' (OO) has become a little fuzzy, since it has been excessively misused in marketing campaigns and blurry language definitions.

An object oriented language encapsulates code and data definitions in templates called classes . A class contains data definitions, procedures, and public procedures (aka methods). Each class can be instantiated by declaring an object (aka instance) of that class. Each object contains copies of all the data objects defined inside of its class. (The term object is used to refer to instances of classes in this section. Variables and vectors are referred to as data objects.) The data contained in an object may only be accessed by procedures defined in its class. No procedure, which is not contained the the class of an object, may ever access any data of that object. This principle is called encapsulation. It is a fundamental property of OO languages.

Each class may have multiple instances (objects). In this case, each object of the class has its own private data area. This is why classes may be reused. Manipulating one object has no effect on other objects of the same class. To reuse a class does not necessarily mean to use the same class in a later project. Except for some very general cases, designing classes with future projects in mind is not worth the extra effort.

Methods of classes are invoked by sending messages to objects of that class. A message is similar to a procedure call. It may transport arguments 'into' the object and the object may return a value to the caller. Since the method is part of the class of the object, it is allowed to manipulate data inside of the object. This way, methods provide a clean and abstract interface to the data of an object. The data structure itself is hidden from the user and may change without changing the interface. This is the greatest advantage of the encapsulation principle.

Other languages define additional concepts like inheritance, protected and public variables, virtual methods, friend relationships, class variables, etc, but most of these concepts are semantically hard to handle and undermine the object oriented principles. All concepts that are actually necessary to define an object model are

Previous:
2.9 The T3X Object Model
TOC | Index | Back Next:
2.9.2 Classes