Monday, March 5, 2018

Essential Features of Object Oriented Programming (OOP)

Principle Feature of Object Oriented Programming (OOP), Features that differentiate Object Oriented Programming from Structured Programming

Features of Object Oriented Programming (OOP)
Object oriented programming is the fundamental concept that encapsulates both data and functions to operate the data into a single unit called as object. It can also be defined as programming paradigm based on the concept of “objects” which may contain data, in the form of attributes and code in the form of procedures(methods). One of the worth feature of OOP is objects that object’s procedures can access and often modify the data fields of the object with which they are associated. Some other main features of OOP including object as feature are as follows;


1) Objects and classes
One of the basic concepts underlying OOP is objects and classes. A class is defined as a collection of similar entities which have same structure and exhibit same behavior. These classes can describe any real world things like organizations, places, occurrences etc and defines the structure and behavior of these sets of entities called objects. As opposed to actual objects, the class gives a general descriptions of all the attributes and methods which will become part of each object created from the class.

Class Definition (C++)

Class rectangle {
Public:
Int length;
Int breadth;
};

Class definition starts with the “class” keyword followed by the class name having class body enclosed by a pair of curly braces.

Object Definition (C++)

rectangle rect1;               
rectangle rect2;

Here ‘rect1’, ‘rect2’ are the objects of class ‘rectangle’.

2) Abstraction
Abstraction is the assence of OOP. It is the representation of the essential features hiding the irrelevant functionality or properties. Or it can be defined as a view of a problem that extracts the essential information relevant to a particular purpose, ignoring the remainder of the information. In OOP, abstraction is achieved by the help of class, where data and methods are combined to extract the essential features only. For example, a car can be looked at different abstraction by different people. A designer would be concerned about minute details like designing the fuel tank, ignition system etc. A buyer would be concerned about colour, mileage, shape, manufacturer ignoring other properties.

3) Encapsulation
Encapsulation is the process of combining the data and functions into a single framework called class. It helps preventing the modification of data from outside the class by properly assigning the access privilege to the data inside the class. It is also considered as separation of the external aspects of an object which are accessible to other objects, from the internal implementation details of the object, which are hidden from other objects.

4) Information hiding (Data hiding)
Information hiding is the state of hiding data or details of an object that do not contribute to its essential characteristics. Typically structure of an object as well as the implementation of its methods is hidden from other objects. The interface of an object is chosen to reveal only the desired data or working of the object. Data hiding are of two types; functional information hiding and data hiding. Functional information hiding relates to the hiding of implementation details of methods and data hiding relates to hiding of structural information of a particular object.

5) Inheritance
Inheritance is the process of acquiring certain attributes and behaviors from parents. For examples, cars, buses, trucks and motorcycles inherit all characteristics of vehicles. Object oriented programming allows classes to inherit commonly used data and functions data and functions from other classes.  If we derive a class from another class, some of the data and functions can be inherited so that we can reuse the already written and tested code in our program, simplifying our program.

6) Polymorphism
Polymorphism is defined as the quality of having more than one form. The representation of different behaviors using the same name is called polymorphism. However the behavior depends upon the attribute, the name holds at particular moment. It provides the programmers with the flexibility of processing any object differently depending upon their data types. Objects of different types can receive the same message and respond in different ways provided these objects have the same method definition.

7) Message passing
In object oriented programming, objects are created for interaction and later destroyed when their job is over. This interaction is based on ‘messages’ which are sent from one object to another asking the recipient object to apply one of its own methods on itself and hence, forcing a change in its state. The objects are made to communicate or interact with each other with the help of a mechanism called message passing. The method of any object may communicate with each other by sending and receiving messages in order to change the state of the object.

No comments:

Post a Comment