Object oriented programming, tutorial
Authors: Alfonseca Manuel 
Published: January 2007

A classical procedural program (written in COBOL, FORTRAN, BASIC, PASCAL, LISP or APL2) is made of sentences that execute sequentially in a predefined order, that depends only on the values of the data the program is working with. This order can usually be deduced by visual inspection of the program.

A non-procedural program (written in PROLOG, for instance) contains a certain number of instructions that will not be executed in a predefined order. They receive control from an
inference processor
, a procedural program that decides in every moment the order in which the sentences of the program should receive control (should be fired).

In both the procedural and the non-procedural cases, the basic unit of execution is the
program
. The data only provide values that will be used to perform computations or to decide the order of execution. A given application is a hierarchical set of programs (modules) each of which is capable of invoking other programs in the hierarchy. The data may be global (accessible from every program in the hierarchy) or local (accessible by the program where they belong and, sometimes, by those at a lower level in the hierarchy).

In Object-Oriented Programming (OOP in short), things are different. Here it is the
data
that are organized in a basic control hierarchy. One piece of data may be linked to another through a relation of descendancy, and this fact gives rise to a network (usually a tree) similar to the hierarchy of programs in procedural programming. There are also programs in OOP, but they are appendages to the data (in the same way as in classical programming data are appendages of programs). It is possible to build global programs (accessible to all the data in the hierarchy) and local programs (accessible from certain objects and their descendants).

In OOP, the execution of a program is fired by means of a
message
that somebody (the user, another program or an object) sends to a given object. The recipient of the message decides which program should be executed (it may be a local program, or a global program which must be located through the network that defines the structure of the objects).

There is a certain amount of confusion on what is Object-Oriented Programming and what is not. This has happened before, with other fields in Computer Science. There are still people, for instance, that call Artificial Intelligence to any program that is written in Prolog or Lisp. In the same way, there are those who maintain that any program written in Smalltalk, C++ or Objective C is OOP. As in the AI example, this is not always the case.
Another source of confusion comes from the fact that Object-Oriented Programming has been frequently used to build complicated user interfaces, with window systems, icons and so forth, and this has produced the unexpected results that many people believe that any program including these interfaces is OOP. Again, this is obviously wrong.
The basic elements of OOP are Objects, Methods and Messages.

An Object is a complex data element that possesses structure and is a part of an organization. It embodies three different concepts:

A set of relations to other objects (usually represented by pointers).

A set of properties (which have values).

A set of methods (defined by means of executable code).

A method is a procedural program written in any language. What other programming systems call functions, programs or procedures, Object-Oriented Programming calls methods. There is no essential difference between programs in any language and methods, except for the fact that in pure OOP the CALL instruction is not allowed. The reason for this is obvious: the CALL instruction is