Object Orientation is the software engineering concept which represents the software as a cluster of distinct objects. Each object comprises both data structure i.e. it’s storage structure and functioning i.e. its behaviour.
In object orientation concept data structure and behaviour of each object is tightly coupled. The object orientation concept is broadly classified into four aspects as discussed below.
Four Concepts of Object Orientation
Identity the term itself means identification or specification of the entities present in the data. The discrete or distinguishable entities present in the data are termed as an object. The object can be basically identified into two categories concrete objects and conceptual objects.
Concrete objects are those which can be sensed like an account in a bank, file in a file system. We access or sense these object. Conceptual objects are those which are based on the concept like a policy of a bank which cant be sensed but it is there in the data.
So, every object has a distinct identity. Even if two objects have all the attribute values same then also, they are discrete and can be identified uniquely. Like, for example, consider two cars of a same company, of the same model, same colour but still, we will consider the two cars as different entity.
In a programming language, these objects can be accessed using a unique handle. Different languages implement this unique handle using the address, array index, pointers etc. The content of an object i.e. attributes of an object can’t be changed by the user directly, it can only be changed by the method of the object. This prevents the inconsistency of the object.
In object orientation the classification is based on the object’s structure and behaviour. The objects that possess the same data structure and function are classified to a group termed as a class in object orientation. For example, we consider a class Shapes then instances of these class such as triangle, square, hexagon etc. will be termed as objects.
Now, we can group all instances or objects i.e. square, triangle, hexagon etc. to a class Shape as they all will have same data structure i.e. side, colour, vertices etc. and they will have same functions like, draw, erase, move etc.
If we talk of class, then a class is an abstraction that means a class incorporate only those data structure and behaviour of the object that is important from the application point of view and it ignores the rest.
The objects belonging to the same class have the same attributes (data structure) and operations or function (behaviour). But each instance or object possesses its own value for attributes which makes it different from other objects belonging to the same class. These objects are directly referenced through their class.
Inheritance is the most important concept in object orientation. Inheritance refers to the sharing of attributes and functions between the two classes. This sharing is based on the hierarchical relationship. Among the two classes that share attributes and functions, one is the super class and the other is sub class.
The super class always has the general attributes and functions that are common in both super class and sub class whereas the sub class inherit all the attributes and functions of its super class and also add its own attributes and functions.
When a sub class is declared using object orientation it does not have to redeclare the attributes and functions of its super class. Sub class simply inherit all the features of its super class. For example, we have a super class Vehicle and two sub classes Bicycle and Car.
Now, the general attribute of Vehicle like name, wheels, seats, etc. will be shared by both the sub classes. But the sub class Bicycle would add its unique feature paddles and sub class Car would add feature fuel-type.
In object orientation, the concept of inheritance where the sub class reuses the features of super class reduces the repetition of code which in turn reduces the size of source code. This was one of the main advantages of object orientation.
Polymorphism in object orientation means ‘of many forms’. In object orientation, a function or an operation is considered as polymorphic according to which a single function acts in a different way for different classes. Whenever a particular class implements a particular function it is termed as a method.
Now let us take an example of a class person. A person behaves or functions differently in a different situation. On the basis of the situation provided, he may behave like an employee, a father, a brother, a son etc.
In a similar way, the programming language based on object orientation allows the selection of the correct method provided the operation name and the object name that is being operated. It is not essential for the user of the application to have knowledge about the methods that are there in the application to execute a polymorphic function.
So, this is all about the object orientation. We have discussed all the important features of object oreintation such as identity, classification, inheritance and polymorphism.