Skip to main content icon/video/no-internet

Object orientation (OO) is an approach to modeling and software engineering that encapsulates both data and the algorithms that operate on them into a single packet or object that is representative of some phenomenon. These objects in effect know what they are (their attributes) and what they can do (their algorithms, called methods) in response to messages from the outside world.

Objects are organized into classes, which can have an inheritance structure whereby they have parents from whom they can inherit both attributes and methods, and they may have children, called subclasses, to which they pass on their attributes and methods. It is also possible to have multiple inheritances in which there are two parents for a single child. Classes that cannot be instantiated are called abstract classes (e.g., it is not possible to have a generic car). An example of a class that can create an instance is a Maserati class of car.

An interesting characteristic of OO is the ability to create new data types, a concept known as abstraction. Traditional computing languages have a set of data types to describe data, such as integers, real, character, and so on. To create more complex features, records are created that are a composite of these types. The problem is that these records cannot be treated like fundamental data types. So, it would not make sense to have a list (a data structure containing a set of objects) that includes a person record, a real number, and a character. In the OO world, this is not a problem, as all objects are treated the same. Thus, any combination is possible, including combining the fundamental data types and more complex ones.

The concept of encapsulation is central to OO. Encapsulation is the concept that objects combine information and behavior in a single packet and that data within the object can be accessed only through messages to the object. This has three consequences: (1) Encapsulation provides a well-defined and strictly enforced interface to an object; (2) it enhances data integrity by screening requested changes in the object's attributes; and (3) it is possible to change the internal code for the method without affecting the interface (i.e., the message stays the same, while the method initiated may be different).

Another powerful principle of OO is polymorphism. This is the ability of multiple object classes to understand the same message. For example, consider the following object methods that define how area is determined for several different geometries:

These methods can then be used by a single set of generic code that defines the general method for determining area for any kind of geometry:

Thus, polymorphism enables the addition of new object classes with minimal change to existing software code. If we add a new object triangle, no change in the code is required. All that is needed is to add the object to the code and write the appropriate method for the area of a triangle.

Some OO languages do not support multiple inheritances and have come up with a solution that enables multiple classes to have the same set of behaviors in common. The description of this set is called an interface. An interface is like a contract that says, “If you want to provide this set of capabilities, you need to implement these methods with these properties and indices and provide support for these events.” Interfaces have become a powerful tool in OO programming languages and another tool in the OO “toolbox.”

...

  • Loading...
locked icon

Sign in to access this content

Get a 30 day FREE TRIAL

  • Watch videos from a variety of sources bringing classroom topics to life
  • Read modern, diverse business cases
  • Explore hundreds of books and reference titles

Sage Recommends

We found other relevant content for you on other Sage platforms.

Loading