Object Oriented Programming ( OOP )

A computer program to solve a real life problem revolves around two things : data and functions. A function is a set of instructions which operates on the data to achieve a solution to a problem.

Procedure Oriented Programming Approach
In this approach, problem is viewed as a sequence of tasks and a number of functions are written to accomplish those tasks. Functions are the primary focus and data is secondary. In simple words, emphasis is more on the algorithm to solve a problem rather than the data on which algorithms operate. A system is designed as combination of smaller programs or functions and data moves around the system from function to function. A complex system designed using this approach becomes very difficult to maintain and extend in future.

Object Oriented Programming Approach
This approach emphasizes more on data rather than functions. Data doesn’t flow freely around the system and are closely coupled to the functions which operate on them. A program to solve a problem is decomposed into entities known as objects and then data and functions are associated with those objects. A system is designed as a combination of objects which consists of related data and functions which manipulate those data. A complex system is easily maintainable and extendible if this approached is followed.

Basic Concepts of Oriented Programming ( OOP )
Objects are the basic entities or building blocks of a system designed using OOP approach. Each object consist of some data and the functions which operates on those data. For e.g, in an Employee Management System , there could be an object named employee. This object can have data like emp_id , emp_salary, serve_period and functions like computeBonus ( ) , increment ( ) which operates on the object data.

Classes are user defined data types which defines the structure of an object. An object is a variable of type class. For e.g, english could be an object of class language.

Data Encapsulation is the wrapping up of data and functions into a single unit called class. Encapsulation binds the data to the functions which operate on them.

Data Abstraction is an act of hiding all the internal details and representing only the essential features of a system. In a class, the data members and the some of the functions which manipulate the data are abstracted and only some functions are exposed to objects of other classes. Abstraction separates implementation and interface. Data members and functions which focus on implementation of some algorithms are abstracted and the functions which are exposed forms the interface through which objects of other classes communicate with the object of this class.

Inheritance provides the concept of code reusability in OOP. While creating a new class, instead of defining completely new data members and functions, we can inherit those members (if they exist) from an existing class. The existing class is known as base class and the new class which inherits from base class is known as derived class. With this feature, we can add new functionalities to an existing class without modifying it.

Polymorphism is the ability of a message to be processed in more than one way. An operation may exhibit different behaviours in different instances depending on the types of data. Consider the operations shown below :

5 + 7 = 12                               ( Addition Operation )
Hello + World = HelloWorld ( Concatenation Operation )

We see that ‘ + ‘ operator behaves differently depending on the operands. Here ‘ + ‘ operator is overloaded. We will discuss the concept of operator overloading later in the tutorial.

All the OOP concepts discussed in this section will become clear as you proceed further with the tutorial. All these terminologies will be explained with examples in later sections.

About    Contact    Sitemap    Terms    Privacy