OOP - Abstraction

Abstraction in OOP

There are many concepts associated with abstraction, some of which can be applied to OOP.

Representational Abstraction

Removing unnecessary details so as to represent the entity only using details that are necessary to the solving of the problem.

In OOP we create objects to represent real world entities. It is not necessary to store every detail of an entity, only those details that are required to solve a problem. For example, a payroll system that stores details of employees does not need to know the employees favourite colour to calculate their wages.

Generalisation Abstraction

Grouping entities together by common characteristics to achieve a hierarchical relationship.

By grouping entities together by what they have incommon, we can create a template for that object. This template is called a class.

Functional Abstraction:

Hides the process from the user (e.g. the driver of a car turns the steering wheel, they don’t need to know if it is rack-and-pinion or linkage system)

Information Hiding:

Information Hiding only allows the user to see/access the data that form the essential characteristics of the object.

OOP does this through the process of encapsulation.

Key Terms

Entity

A single person, place, or thing about which data can be stored

Class

A template that describes the attributes and behaviours for a group of entities

Object

The representation of an entity. It is created from the template. An object is an instance of a class.