Thursday, May 2, 2019

Difference between procedural programming and object oriented programming

Traditional Procedural Programming


In traditional, procedural programming, data and functions (subroutines, procedures) are
kept separate from the data they process. This has a significant effect on the way a pro-
gram handles data:
■ the programmer must ensure that data are initialized with suitable values before
use and that suitable data are passed to a function when it is called
■ if the data representation is changed, e.g. if a record is extended, the correspon-
ding functions must also be modified.
Both of these points can lead to errors and neither support low program maintenance
requirements.


Objects-oriented programming 


Object-oriented programming shifts the focus of attention to the objects, that is, to the
aspects on which the problem is centered. A program designed to maintain bank
accounts would work with data such as balances, credit limits, transfers, interest calcula-
tions, and so on. An object representing an account in a program will have properties
and capacities that are important for account management.
OOP objects combine data (properties) and functions (capacities). A class defines a
certain object type by defining both the properties and the capacities of the objects of
that type. Objects communicate by sending each other “messages,” which in turn acti-
vate another object’s capacities.

Advantages of OOP

Object-oriented programming offers several major advantages to software development:
■ reduced susceptibility to errors: an object controls access to its own data. More
specifically, an object can reject erroneous access attempts
■ easy re-use: objects maintain themselves and can therefore be used as building
blocks for other programs
■ low maintenance requirement: an object type can modify its own internal data
representation without requiring changes to the application.                                                               


      previous                                                      Next          

No comments:

Post a Comment

Array

Arrays  An array is a series of elements of the same type placed in contiguous memory locations that can be individually referenced by ad...