Procedural Vs Object-Oriented Approach
Procedural Vs Object-Oriented Approach
Object-Oriented programming
The prime function of developing object-oriented approach is to remove
some of the shortcomings associated with the procedure oriented
programming. OOP has data as a critical component in the program
development. It does not let the data flow freely around the systems.
OOP permit us to analyze a problem into number of items known as
objects and then assembles data and functions around these items. The
important characteristics of Object –Oriented Programming are as
follows:
Objects
Classes
Methods
Data Abstraction
Encapsulation
Inheritance
Polymorphism
Dynamic Binding.
Message Passing
Reusability
Delegation
Genericity
Objects
Objects are primary run-time entities in an object-oriented
programming. They occupy space in the memory. Each object has its
own properties or features. An object is a specimen of a class. It can be
singly recognized by its name. It declares the state shown by the data
values of its characteristic at a specific time. The action of object
depends upon the member function defined within its class.
Classes
A class is grouping of objects having identical properties, common
behaviors, and shared relationship. A class is a blueprint or prototype
from which objects are created. This section defines a class that models
the state and behavior of a real-world object. It intentionally focuses on
the basics, showing how even a simple class can cleanly model state and
behavior.
Method
An operation required for an object or entity when coded in a class is
called a method. All objects in a class perform certain common actions
or operations. Generally the data members are declared private, and
member functions declared public. We can also define public data
members and private member functions. The data member of any class
uses its member functions or methods to perform operations.
Data abstraction
Encapsulation
The grouping of related items into one unit.
One of the basic concepts of OO.
Attributes and behaviors are encapsulated to create objects.
OO modeling is close to how we perceive the world.
Implementation details are hidden from the outside world. We all
know how to use a phone, few of us care how it works.
The packaging of operations and attributes representing state into
an object type so that state is accessible or modifiable only
through the objects' interface .
Encapsulation lets builders of objects reuse already-existing
objects, and if those objects have already been well-tested, much
larger and more complex systems can be created.
Inheritance
A subclass is derived from a super class.
The subclass inherits the attributes and behavior of the super
class.
The subclass can override the behavior of the super class.
Notice the use of the ``Is-A'' phrase to describe inheritance.
Inheritance promotes re-use.
Polymorphism
Dynamic Binding
Binding means connecting one program to another program that is to
be executed in reply to a call. Dynamic binding is also known as late
binding. The code present in the specified program is unknown till it is
executed.
Message Passing
Objects communicate by sending messages.
Messages convey some form of information.
An object requests another object to carry out an activity by sending it a
message.
Reusability
Object-Oriented technology allows reusability of the classes by
extending them to other classes using inheritance. Once a class is
defined the other programmer can also use it in their programs and add
new features to the derived classes.
Delegation
In OOP, two classes can be joined either by – inheritance or delegation.
In inheritance, one class can be derived from the other class and
relationship between them is known as kind of relationship. The second
type of relationship is has a relationship. When object of one class is
used as data member in other class , such composition of objects is
known as delegation.
Genericity
The software components of a program have more than one version
depending on the data type of arguments. This feature allows
declaration of variables without specifying exact data type. The
compiler identifies the data type at the run-time.
Advantages of OOP