0% found this document useful (0 votes)
2 views7 pages

Procedural Vs Object-Oriented Approach

The document discusses procedural programming and its limitations, highlighting the transition to object-oriented programming (OOP) as a solution. OOP emphasizes data encapsulation, inheritance, and polymorphism, allowing for more flexible, maintainable, and reusable code. It contrasts traditional procedural approaches with OOP, showcasing the benefits of design, communication, and adaptability in software development.

Uploaded by

Saarthak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views7 pages

Procedural Vs Object-Oriented Approach

The document discusses procedural programming and its limitations, highlighting the transition to object-oriented programming (OOP) as a solution. OOP emphasizes data encapsulation, inheritance, and polymorphism, allowing for more flexible, maintainable, and reusable code. It contrasts traditional procedural approaches with OOP, showcasing the benefits of design, communication, and adaptability in software development.

Uploaded by

Saarthak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Procedural Programming

Procedural programming is sometimes used as a synonym for


imperative programming (specifying the steps the program must take to
reach the desired state), but can also refer to a programming paradigm
based upon the concept of the procedure call. Procedures, also known as
routines, subroutines, methods, or functions simply contain a series of
computational steps to be carried out. Any given procedure might be
called at any point during a program's execution, including by other
procedures or itself.
Traditional programming languages such as COBOL, FORTRAN etc
are commonly known as procedure oriented languages. The program
written in these languages consist of sequence of instructions that tell
the compiler or the interpreter to perform the given task. When the
program code is large then it becomes inconvenient to manage it. To
overcome this problem, procedures or subroutines were adopted to
make a program more understandable to the programmers. A program
is divided into many functions. Each function has its own task. If the
program is too large the functions also creates problems.

Drawbacks observed in monolithic, procedural, and structured


programming languages:

 Large size programs are divided into smaller programs known as


functions these functions call one another. Hence security is not
provided.
 Importance is not given to the security of data but on doing the
things.
 Data passes globally from one function to another.
 Most functions have access to global data.

Object Oriented Approach


(1) The various objects in system are identified.
Collection of discrete objects that incorporate data structures and
behavior.
Each data structure has, combined with it, the procedures which apply
to that data structure.
Contrasts with conventional programming in which data structures and
behavior are only loosely connected
These entities, called objects, can be associated to one another in one
network, rather than two.
(2) It is very close to the real world.
(3) Maintenance is localized so less costly and less error prone even
when requirements change.
(4) We can reuse the code rather than starting the project from scratch.
(5) Systems are more flexible, more easily extensible.
(6) Prototyping and evolutionary deliveries are better supported thus
reducing time-to-market.
(7) Information hiding through encapsulation helps to build secure
system.
(8) Much Stress is on the design phase.
(9) User’s and developers vacabulary is same in OOP.

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:

 OOP pay more importance to data than to function.


 Programs are divided into classes and their member functions.
 New data items and functions can be comfortably added
whenever essential.
 Data is private and prevented from accessing external functions.
 Objects can communicate with each other through functions.
 Follows bottom-up approach.
The most natural implementation for an object-oriented design is an
object-oriented language. Its easy since language constructs are similar
to the design constructs. In general, an object-oriented language
supports objects, polymorphism at run-time, and inheritance.

Key Concepts Of Object-Oriented Programming

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

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.

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

 Literally means ``many forms''.


 A method can have many different forms of behavior.
 Commonly used between a set of classes that have a common
super class.
 The sender of a message does not have to know the type/class of
the receiver.
 A single operation or attribute may be defined upon more than
one class and may take on different implementations in each of
those classes.
 An attribute may point to different objects at different times.

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.

(Static Binding) If the type T of a variable is explicitly associated with


its name N by declaration, we say, that N is statically bound to T. The
association process is called static binding.

(Dynamic Binding) If the type T of a variable with name N is implicitly


associated by its content, we say, that N is dynamically bound to T. The
association process is called dynamic binding.

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

1. Object oriented programs can be comfortably upgraded.


2. Using inheritance, redundant program code can be eliminated
and use of previously defined classes may be continued.
3. The technology of data hiding facilitates the programmer to
design and develop safe programs that do not disturb code in
other parts of the program.
4. The encapsulation feature provided by OOP languages allows
programmer to define the class with many functions and
characteristics and only few functions are exposed to the user
5. All the object-oriented programming languages can create
extended and reusable parts of programs
6. Object-oriented programming enhances the thought process of a
programmer leading to the rapid development of new software in
short span of time.
Traditional/Procedural Vs Object-oriented programming

Traditional Approach Object-Oriented Approach


(1)The focus of procedural (1) In object oriented
programming is to break down a programming it is to break down
programming task into a collection a programming task into objects.
of data structures and subroutines.
(2) We have functions in procedural (2) We have methods in object-
approach. oriented approach.
(3) In procedural approach the (3) In the object oriented
functions call one another. approach the various objects
communicate through message
passing.
(4) In procedural approach we have (4) In object-oriented approach
variables. we have data members.
(5) Much stress is not given on (5) Much stress is given on the
design phase design phase.
(6) Requirement Specifications must (6) Requirement specifications
be complete before designing. may not be complete before
designing. New requirements
may evolve during any phase.
(7)Does not support changes. Its (7) asystem are more flexible,
difficult to make changes more easily extensible.
(8) System developed using this (8) System developed using this
approach is costly to maintain. approach is less costly to
maintain.
(9)We have to make system from (9) Reusable code is available
scratch. rather than starting from
scratch.
(10) Because of ineffective (10) The user’s and developer’s
communication, user’s and vocabulary is same.
developer’s vocabulary is different.
(11) Waterfall model is used and so (11) The main motive of the
problems are more severe. system development life cycle is
to reduce the complexity of the
solution of a complex problem.

You might also like