Basic Concepts of OOPS

05 min read

Object-oriented programming (OOP) is a programming paradigm that uses "objects" —data structures consisting of data fields and methods together with their interactions — to design applications and computer programs. It includes concepts such as

  • Objects
  • Classes
  • Data abstraction
  • Data encapsulation
  • Inheritance
  • Polymorphism
  • Dynamic binding
  • Message Passing

1) Objects

  • Basic runtime entities in an object-oriented system.
  • May represent a person, a place or a thing with which the computer must deal.
  • Objects can be Concrete (eg: file system) or Conceptual (eg. scheduling)
  • Objects serve the following purposes: Understanding of the real world and a practical base for designers and Decomposition of a problem into objects depends on judgment and nature of the problem.

2) Classes: A class encloses both data and functions that operate on the data, into a single unit.

3) Data Abstraction

  • Data Abstraction refers to representing essential features without including the background details or explanations.
  • It is the process of abstracting common features from object and procedures and creating a single interface to complete multiple tasks.

4) Data Encapsulation

  • The mechanism that binds together the data and the code that manipulates it and keeps them safe from outside interference and misuse.
  • That is, the data is not accessible to the outside world and only those functions which are wrapped in the class can access it.
  • Elimination of direct access to data is Data Hiding.

5) Inheritance

  • Inheritance is the process by which objects of one class acquires the properties of objects of another class.
  • Inheritance provides the idea of reusability.
  • Additional features can be added to an existing class without modifying it. Each subclass (derived) defines only those features that are unique to it. Without this, each object would need to define explicitly all of its characteristics.

6) Polymorphism

  • Characterized by the phrase "one interface, multiple methods".
  • Polymorphism means the ability to take more than one form.
  • Allows objects having different internal structures to share the same external interface.
  • Example — One doesn't have to understand how the engine works to drive a car.

7) Dynamic Binding

  • Binding refers to the linking of a procedure call to the code to be executed in response to the call.
  • Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time (Associated with polymorphism and inheritance).

8) Message passing

  • Objects communicate with one another by sending and receiving information much the same way as the people pass messages to one another.
  • A message for an object is a request for execution of a procedure and therefore will invoke a method in the receiving object that generates the desired result.
  • In procedural programming, functions operate based on either local or global, while in object-oriented programming, objects exists and objects interact with other objects.

 

Benefits of Object-Oriented Programming

  • Through inheritance, we can eliminate redundant code and extend the use of existing classes.
  • We can build programs from standard working modules that communicate with one another rather than, having to start writing the code from scratch. This leads to saving of development time and higher productivity.
  • The principle of data hiding helps the programmers to built secure program that can't be invaded by code in other parts of the program.
  • It is possible to have multiple objects to coexist without any interference.
  • It is possible to map objects in the problem domain to those objects in the program.
  • It is easy to partition the work in a project based on objects.
  • The data-centered design approach enables us to capture more details of the model in an implementable form.
  • Object-oriented systems can be easily upgraded from small to large system
  • Message passing technique for communication between objects makes the interface descriptions with external system much simpler.
  • Software complexity can be easily managed.
POST A NEW COMMENT
     
  • Input (stdin)

    Output (stdout)


    Input (stdin)

    Your Output (stdout)

    Expected Output

    Compiler Message

    Input (stdin)

    2    3

    Your Output (stdout)

    5

    Expected Output

    5

    Compiler Message

    5

    Error