Object, Class, Data, Encapsulation and Abstraction, Data Hiding, Inheritance, Polymorphism, Dynamic binding, Message Passing: Basic Concepts of Object Oriented Programming

Object, Class, Data, Encapsulation and Abstraction, Data Hiding, Inheritance, Polymorphism, Dynamic binding, Message Passing: Basic Concepts of Object Oriented Programming  

Basic Concepts of Object Oriented Programming  ,




1.     Object
2.     Class
3.   Data   Encapsulation and Abstraction
4.     Data Hiding
5.     Inheritance
6.     Polymorphism
7.      Dynamic binding
8.     Message Passing

1.Object:  Objects are the basic run-time entities in an object-oriented system. Programming problem is analyzed in terms of objects and nature of communication between them. When a program is executed, objects interact with each other by sending messages. Different objects can also interact with each other without knowing the details of their data or code.
  1. An Object is an Instance of a Class. An Instance is the existence in the computer system by acquiring a memory space. 
  2. An Object is the only way a Class becomes usable.
  3. Objects are basis of Object Oriented Programming.
  4. An Object has all the Characteristics of the Class using which the Object is created.
  5. It implements reusability of code written in Classes.
      Object: student

         DATA
            Name
           Date of birth

FUNCTIONS
          Total
          Average
 
                                        

2. Classes:  A class is a collection of objects of similar type. Once a class is defined, any number of objects can be created which belong to that class. In fact, objects are
variables of the type class. Once a class has been defined, we can create any number of objects belonging to that class.

  1. A Class is a Blueprint or Stencil for creating Objects.
  2. A Class specifies all the Member Data and Member Functions that would be present in the Objects created using the Class.
  3. Using a Class any number of Objects can be created.
  4. It’s a User Defined Data Type also called Abstract Data Type, which acts like a basic data type when used.
  5. Usually Classes are used to represent computer understandable formats for Real World Entities.
3. Data Abstraction and Encapsulation
      Abstraction refers to the act of representing essential features without including the background details or explanations. Classes use the concept of abstraction and are defined as a list of abstract attributes. Storing data and functions in a single unit (class) is encapsulation. Data cannot be accessible to the outside world and only those functions which are stored in the class can access it.
     Abstraction :-
  1. It’s the process of Hiding the complexities of implementation and providing a simple Interface for easy use.
  2. Its implemented using Encapsulation.
  3. Functions, Structures and Classes implement Abstraction at programmer level.
    Encapsulation :-
  1. It’s the process of wrapping up of Data and Functions inside a single Entity (usually Classes).
  2. Encapsulation helps to establish Abstraction and Data Hiding.
  3. Functions, Structures and Classes implement Encapsulation at programmer level.
5.     Data Hiding :-
It’s the process of keeping the Data under such an Access mode that its only accessible to permitted Functions.Using Private, Protected specifiers, we can hide Data from access from outside a Class. Functions, Structures and Classes implement Data Hiding at programmer level.
6. Inheritance
Inheritance is the process by which objects can acquire the properties of objects of other class. In OOP, inheritance provides reusability, like, adding additional features to an existing class without modifying it. This is achieved by deriving a new class from the existing one. The new class will have combined features of both the classes.
  1. Here the Class which gets the Inherited properties is called the Child Class and from which it acquires the properties is called the Base or Parent Class.
  2. During Inheritance the Protected and Public Data and Functions get passed on as copies from the Parent or Base Classes to Child Classes.
  3. It forms a Hierarchical Structure from Parent down to Children Classes.
  4. It implements Reusability of Parent Class Data and Functions.
  5. Structures and Classes can be used to implement Inheritance.
  6. Types :- Single, Multilevel, Multiple, Hierarchical and Hybrid.

7. Polymorphism
Polymorphism means the ability to take more than one form. An operation may exhibit different behaviors in different instances. The behavior depends on the data types used in the operation. Polymorphism is extensively used in implementing Inheritance using same name with either Different number of Arguments or Different Data types of Arguments.
Types:- Compile Time (the compiler recognizes the binding between the function and its code during compile time) and Run Time(the compiler recognizes the binding between the function and its code during runtime)

8.     Dynamic binding :-
  1. Its also called Runtime Polymorphism, where the compiler recognizes the binding between the function and its code during runtime.
  2. Its implemented using Virtual Functions, during Inheritance.

9.     Message Passing :-
  1. It’s the process of passing Data between Objects of same Class and also of different Classes.
  2. Its implemented using Function calling or by simply sharing data.
  3. Types:- From User to Objects (done by invoking Function inside an Object) and From Object to Object (by sharing Data of one Object with another Object).
  4. Using Friend functions (with objects as input arguments), message passing can be done between two or more Objects of Different Classes.
  5. Using member Functions (with objects as input arguments), message passing can be done between objects of same Class.

Labels: