× back Beginning with OOP Features of OOP Difference b/w POP and OOP Basic concept of OOP Benifit of OOP Applications of OOP
Next Topic →

Beginning with OOP

Features of OOP are:

Difference between POP (Procedural Oriented Programming) and OOP (Object Oriented Programming)

Basic concepts of OOP

It is necessary to understand some of the concepts used extensively in OOP
These include:

Classes

  • In a nutshell, classes are essentially user-defined data types. Classes are where we create a blueprint for the structure of methods and attributes. Individual objects are instantiated from this blueprint.
  • The entire set of data and code of an object can be made a user-defined data type with the help of a class.

Objects

  • Objects are instances of a class created with specific data.
  • Objects are the basic run-time entities in an object-oriented system.
  • They may represent a person, a place, a bank account, a table of data or any item that the program has to handle.
  • Programming problem is analyzed in terms of objects and the nature of communication between them.
  • Program objects should be chosen such that they match closely with the real-world objects.
  • When a program is executed the objects interact by sending messages to one another.

Data Abstraction and Encapsulation

  • The wrapping up of data and functions into a single unit (called class) is known as encapsulation.
    • Data encapsulation is the most striking feature of a class.
    • The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it.
    • These functions provide the interface between the object's data and the program.
    • This insulation of the data from direct access by the program is called data hiding or information hiding.
  • Abstraction refers to the act of representing essential features without including the background details or explainations.
    • Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost, and functions to operate on these attributes.
    • They encapsulate all the essential properties of the objects that are to be created.
    • The attributes are sometimes called data members because they hold information.
    • The functions that operate on these data are sometimes called methods or member functions.
  • Since the classes use the concept of data abstraction, they are known as Abstract Data Types.

Inheritance

  • Inheritance is the process by which objects of one class acquire the properties of objects of another class.
  • It supports the concept of hierarchical classification.
  • For example, the bird 'robin' is a part of the class 'flying bird' which is again a part of the class 'bird'.
  • The principle behind this sort of division is that each derived class shares common characteristics with the class from which it is derived as illustrated below.
  • In OOP, the concept of inheritance provides the idea of reusability. This means that we can add additional features to an existing class without modifying it. This is possible by deriving a new class from the existing one. The new class will have the combined features of both the classes.
  • The real appeal and power of the inheritance mechanism is that it allows the programmer to reuse a class that is almost, but not exactly, what he wants and to modify the class in such a way that it does not introduce any undesirable side-effects into the rest of the classes.

Polymorphism

  • Polymorphism is another important OOP concept. Polymorphism, a Greek term, means the ability to take more than one form.
  • Polymorphism provides a method of creating multiple forms of a function by using a single function name.
  • This is achieved using function overloading and operator overloading. Function overloading allows multiple functions to have the same name but different arguments, and the appropriate function to be called is determined at compile-time based on the number and types of arguments passed to it. Similarly, operator overloading allows operators such as +, -, *, /, etc. to be used with user-defined data types.

Dynamic Binding

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

Message Passing

  • An object-oriented program consists of a set of objects that communicate with each other.
  • The process of programming in an object-oriented language, therefore, involves the following basic steps:
    1. Creating classes that define objects and their behaviour,
    2. Creating objects from class definitions, and
    3. Establishing communication among objects.
  • Objects communicate with one another by sending and receiving information much the same way as people pass message to one another.
  • The concept of message passing makes it easier to talk about building systems that directly model or simulate their real-world counterparts.

Benefits of OOP

OOP offers several benefits to both the program designer and the user. Object-oriented contributes to the solution of many problems associated with the development and quality of software products. The principal advantages are:

Applications of OOP

References