HomeContentsContents

Object Oriented Programming (OOP) is a style of programming which not only groups procedures and data by functionality but which also applies a few common rules as to how this grouping occurs. In OOP, designers group procedures and data into modules. By doing this it helps to define the purpose of the program and also gives the added benefit of portability (porting a modular segment of code to another program is much easier than porting an integrated segment of code).

These modules (or objects) will generally follow a few guidelines:

Because data and procedures are grouped together, all procedures which handle the specific data should be included within the module. Abstraction and encapsulation occurs when the module abstracts and controls access to the data it manipulates. The internal representation of data used by a module is most likely irrelevant to external sources (with the interface being the primary concern).

An example of abstraction and encapsulation would be a table of people and their pets. The 'People and Pets' module has several procedures:

Add Person
Add a Person to the table. The person and their pet are passed as arguments to this procedure.
Remove Person
Remove a Person from the table. The person to be removed is passed as an argument to this procedure.
Get Pet
This procedure finds the pet for a given person. The person is passed as an argument to this procedure which then returns the pet associated with that person.

In the People and Pets module the table can be internalized in any form. The form is irrelevant to external programs which may use it.

Inheritance is the ability of another module to take on the functionality of an existing module and further expand upon it. For instance, a 'People, Pets and their Names' module could be created which takes on the functionality of 'People and Pets', but expands it to include the names of the pets.

Inheritance is extremely useful because code becomes reusable and extendable without having to re-create each portion or module for different functionality.

In inheritance, a module taking on the functionality of another object is called as a derivation of that object. For instance, 'People, Pets and their Names' is derived from 'People and Pets'. The module 'People, Pets and their Names' is a child of 'People and Pets', with 'People and Pets' being the parent of 'People, Pets and their Names'.


Contents Previous Next Functions

Valid XHTML 1.0 Strict