Tuesday, 29 August 2017

Object Oriented Programming and its basic concepts

Object Oriented Programming (OOP) is a programming paradigm that is based on the concept of objects. It is an approach to problem solving where all computations are carried out using objects. An object is a data structure that contains data (fields) and functions (methods). Object oriented programming aims to implement real world entities like inheritance, hiding in programming. The main aim of OOP is to bind together the data and the functions that operates on them so that no other part of code can access this data except that function. 

Basic concepts of Object Oriented Programming

1. Object: An object is a component of a program that knows how to perform certain actions and how to interact with other elements of the program. Objects are basic run-time entities and are instances of a class.

2. Class: A class is a blueprint of an object. It defines what an object of the class will consist of and what operations can be performed on such an object. A class is needed before creating an object.

3. Data Abstraction: Data abstraction refers to providing only essential information to the outside world and hiding their background details, i.e., to represent the needed information in program without presenting the inside details. For example, a database system hides certain details of how data is stored and created and maintained. In OOP's abstraction feature is provided by methods(function) of a class.

4. Data Encapsulation: Wrapping up(combing) of data and functions into a single unit is known as encapsulation. The data is not accessible to the outside world and only those functions which are wrapped within the class can access it. This insulation of the data from direct access by the program is called data hiding or information hiding. In OOP's encapsulation feature is provided by the class.

5. Inheritance: Inheritance is the process by which objects of one class acquire the properties of objects of another class. Inheritance provides re-usability. This means that we can add additional features to an existing class without modifying it. existing class is called base class and the new class formed is called as derived class.
Inheritance can be of following types:
  • Single Inheritance 
  • Multiple Inheritance 
  • Multi-level Inheritance
  • Hierarchical Inheritance
  • Hybrid Inheritance 

6. Polymorphism: Polymorphism means the ability to take more than one form. Poly refers to many and morphism refers to forms. An operation may exhibit different behaviors in different instances. The behavior depends upon the types of data used in the operation.

7. Dynamic Binding: Dynamic binding means that a block of code executed with reference to a procedure(method) call is determined at run time. It is the process of linking procedure call to a specific sequence of code (method) at run-time. It means that the code to be executed for a specific procedure call is not known until run-time. Dynamic binding is also known as late binding or run-time binding.

8. Message Passing: Objects communicate with one another by sending and receiving information to each other. A message for an object is a request for execution of a procedure and therefore will invoke a function in the receiving object that generates the desired results. Message passing involves specifying the name of the object, the name of the function and the information to be sent.

No comments:

Post a Comment