Navigation  without Java Scripts

Introduction to the Object Oriented Programming (OOP)

Four criteria have to be fulfilled, before a system can be considered to be object orientated:
Encapsulation
Classes
Inheritance
Identity

Encapsulation

The importance of encapsulation and modularity is well known. Encapsulation helps building more structured and readable programs, because objects are treated like black boxes. Look at a complex problem, find a part, which you can declare and describe. Encapsulate it into an object, construct an interface and continue so, until you have declared all the sub-problems. When you have encapsulated the objects of the problem, and ensured, that they work correctly, you can abstract from them.

OOP is also sometimes known as data-driven programming. You can actually let objects themselves do the work for you. They contain methods, which are invoked when objects are created, deleted, and whenever you call them. Methods can call methods of other objects.

Objects and Classes

The way data is stored in traditional programming languages is usually hard to grasp for humans and not suited for modeling. Objects are much easier to work with, because they are closer to the way humans understand real-world objects and in fact objects themselves are a tool for modeling.

Objects are far more complex data structure than lists. At the basic level an object is a declaration of coherent data and predicates, which can work on these data. In OOP-terminology these predicates are called methods. Each class represents a unique set of objects and operations (methods) available to create, manipulate, and destroy such objects.

A class is a definition of an object. An instance is an actual occurrence of this object. Normally you can define as many instances of a class as you like.

For example, if a class "automobile" includes two member-facts: "owner" and "brand", actual instances of the class can be the following:

Actual Instance Owner Brand
Class instance 1 Beatrice Morris Mascot
Class instance 2 John Rolls Royce

Inheritance

OOP is a powerful modeling tool. Objects can be defined on the abstraction level that best suits a problem representation. From this level child-objects can be defined on lower levels, and parent-objects on higher. An object can inherit data and methods from objects at higher levels. Objects are thus an easy way to make very modular programs.

Identity

Every object is unique: objects have a changeable state, and since the state of the objects can be observed by means of their member predicates an object is only identical to itself. I.e. even if the states of two objects are identical, the objects are not identical, because we can change the state of one object without changing the other, and then the objects no longer have identical states.

We never have direct access to an object, we always access an object by means of a reference to an object and while an object is only identical to itself, we can have many references to the same object. Thus, the same object can be accessed through many different references.

Classes are also unique; they are identified by their names. Two classes cannot have the same name in the same program.

See also

References

  1. Meyer, Bertrand :"Object-oriented Software construction" Prentice Hall 1988
  2. Gamma, Erich, Helm, Richard et. al.: "Design Patterns", Addison Wesley 1994