Advertisements

Showing posts with label Definition of OOP's. Show all posts
Showing posts with label Definition of OOP's. Show all posts

Friday, December 28, 2018

What is Object Oriented Programming (OOP's) & It's Features||

Object Oriented Programming (OOP) : OOP allows decomposition of problem into a number of entities called object and then build data & functions around these objects.

  • The data of an object can be accessed only by the functions associated with that object.
  • OOP's as an approach that provides a way of modularizing programs by creating partioned memory area for both data and functions.


Features of OOP:
  • Emphasis is on data rather than procedure.
  • Programs are divided into objects.
  • Data is hidden and cannot be accessed by external functions.
  • New data and functions can be easily added whenever necessary.
  • Follow bottom - up approach in program design.
Concepts of OOP:

Basic concept of OOP are as follows:-
  1. Objects
  2. Classes
  3. Data abstraction and data encapsulation
  4. Inheritance
  5. Polymorphism
  6. Data binding
  7. Message passing
Object:
  • Object are the basis 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, the object interact by sending message to one another.
  • Each object contain data, and code to manipulate the data.

Fig. Way of represeting an object

Classes:
  • A class is a collection of objects of similar type. For Example, mango, apple and orange are member of the class fruit. If fruit has been defined as a class, fruit mango; will create an object belonging to the class fruit.
  • The entire set of data and code of an object can be made a user defined data type with the help of a class.
  • Classes are user defined data type and behave like the build in type of a programming language.
  • Once a class has been defined, we create any number if object belonging to that class.
Data Abstraction and Encapsulation:

Data Abstraction : Abstraction refers to the act of representing essential features without including the background details or explanation.
  • Classes uses the concept of abstraction and are defined as a list of abstract attributes such as size, weight and cost.
  • The functions that operate on these data are called methods.
  • The classes, who use the concept of data abstraction, are know as Abstract Data Types (ADT).
Data Encapsulation: The wrapping up of data functions into a single unit (called class) is know as encapsulation.
  • The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it.
  • This insulation of the data from direct access by the program is called data hiding or information hiding.
Inheritance (Reuseability):
  • Inheritance is the process by which object of one class acquire the properties of objects of another class.
  • The concept of Inheritance provides the idea of reuseability.
  • Reuseability we can add additional features to an existing class with modifying it.
  • The real appeal and power of the inheritance mechanism is that it allows the programmer to reuse a class.
  • Each derived-class defines only those features that are unique to it.


Polymorphism:
  • Polymorphism means one name, multiple forma. It allows us to have more than one function with a same name in a program.
  • It plays an important role in allowing objects having different internal structure to share, the same external interface.
  • The process of making an operator to exhibit different behavior in different instance is know as operator overloading.
  • It is extensively used in implementing inheritance.
Fig. Polymorphism

Dynamic binding or Late 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 know until the time of the call at run time.
  • A function call associated with a polymorphic reference depends on the dynamic type of that reference.
Message Passing:
  • Message passing involves specifying the name of object, the name of the function (message) and the information to be sent.
  • A message for an object is a request for execution of a procedure, and therefore will invoke a function (procedure) in the receiving objects that generates the desire result.
  • Object have as life cycle. They can be created and destroy.
  • Communication with an object is feasible as long as it is alive.