Term of the Moment

datacenter


Look Up Another Term


Redirected from: objects

Definition: object-oriented programming


A programming language structure wherein the data and their associated processing ("methods") are defined as self-contained entities called "objects." Becoming popular in the early 1990s and the norm today, object-oriented programming (OOP) languages, such as C++ and Java, provide a formal set of rules for creating and managing objects. The data are stored in a traditional relational database or in an object database if the data have a complex structure. See O-R mapping and object database.

There are three major features in object-oriented programming that makes them different than non-OOP languages: encapsulation, inheritance and polymorphism.

Encapsulation Enforces Modularity
Encapsulation refers to the creation of self-contained modules that bind processing functions to the data. These user-defined data types are called "classes," and one instance of a class is an "object." For example, in a payroll system, a class could be Manager, and Pat and Jan could be two instances (two objects) of the Manager class. Encapsulation ensures good code modularity, which keeps routines separate and less prone to conflict with each other.

Inheritance Passes "Knowledge" Down
Classes are created in hierarchies, and inheritance allows the structure and methods in one class to be passed down the hierarchy. That means less programming is required when adding functions to complex systems. If a step is added at the bottom of a hierarchy, only the processing and data associated with that unique step needs to be added. Everything else is inherited. The ability to reuse existing objects is considered a major advantage of object technology.

Polymorphism Takes any Shape
Object-oriented programming allows procedures about objects to be created whose exact type is not known until runtime. For example, a screen cursor may change its shape from an arrow to a line depending on the program mode. The routine to move the cursor on screen in response to mouse movement would be written for "cursor," and polymorphism allows that cursor to take on whatever shape is required at runtime. It also allows new shapes to be easily integrated.

OOP Languages
Used for simulating system behavior in the late 1960s, SIMULA was the first object-oriented language. In the 1970s, Xerox's Smalltalk was the first object-oriented programming language, which was used to create the graphical user interface (see Xerox Star). ACTOR and Eiffel were also earlier OOP languages.

Today, C++, C#, Java, Visual Basic.NET and Python are popular object-oriented languages. The following compares basic OOP terms with traditional programming. See object-oriented DBMS.

 OOP           Traditional Programming

 class         define data + processing

 object        data + processing

 attribute     data (a field)

 method        function

 message       function call

 instantiate   allocate a structure




Relational vs. Object Modeling
Instead of separate employee, department and job tables, an employee class contains the data and processing for all employees. Each subclass (manager, secretary, etc.) has its own data and processing but also inherits everything from the employee class. Changes made to the employee class affect every subclass.