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 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:
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 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 deriving from 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'.
Object Oriented Programming | Objects | Language Structure | Implementation | Textdump | Functions | Native Method Reference