Elements of an Object Oriented System

Major Elements

Abstraction

Abstraction focuses on the essential characteristics of an object relative to the perspective of the viewer.

The methods defined within a class should be those that perform the functions that will be required by the routines that are to use the class. If there are two (or more) totally different views of the object that are required in different circumstances then separate classes should be created to provide these views.

Encapsulation

Encapsulation hides the details of the implementation of an object.

The routine using the information does not care how the data required by the object is stored or how the functions of the class relate to that data. By hiding the implementation from the routines that use the class, the internal functionality of a class can be changed without impacting in any way on the routines that use the class.

For example, a class could store information as an array or as a linked list. This should be invisible to the calling routines which will use exactly the same methods to access the class regardless, however the actual functionality that the methods use to add, remove, and extract information from the class will be completely different depending upon which means of implementing the class is selected.

Modularity

Modularity packages abstractions into discrete units.

Each class should only contain those methods which are relevant to the functioning of that class.

Hierarchy

Abstractions form a hierarchy.

By building classes that are derived from other classes, the common functionality of similar classes only needs to be built once and the individual classes need only define those methods which are unique to the particular class.

Minor Elements

Typing

Strong typing prevents mixing abstractions.

The combining of two different classes within the one statement should only be possible where the statement is acting on a common attribute of the two classes provided by a base class from which both classes are derived.

For example, adding two apples and three oranges is meaningless unless you are counting pieces of fruit.

Concurrency

Concurrency allows different objects to act at the same time.

Persistence

Persistence saves the state and class of an object across time and space.