Download as pdf or txt
Download as pdf or txt
You are on page 1of 1

Assignment 1

BY: Umair Khalid Khan 337959 BSCS10 A

Procedural programming paradigm is a model where instructions are executed sequentially,


whereas in Object oriented programming consists of entities that are referred to as
‘objects’. These objects have certain attributes and ‘methods’. For comparisons sake what
we call functions in procedural are called methods in object oriented, and data in procedural
is called attributes in object oriented.
In class based OOP variables are declared as objects of pre (user or built in) defined classes.
Admittedly there are many advantages of OOP over PP.

 The first one would be that real life scenarios are much easier to represent in OOP. For
example, a Car can be a user defined class, which has several attributes (data members)
like model, year, registration number, etc. and certain methods to set these attributes.
Similarly another example can be of a cuboid, whose dimensions can be stored as data
members and methods can be defined to use those dimensions, such as a method that
calculates and returns the volume of the cuboid.

 Security, OOP provides a more secure environment as data members may be not be
allowed to be directly accessible, certain methods would be required to access and
modify data members, eliminating accidental changes to data and hence, ensuring data
integrity. This bundling of data and methods is called encapsulation.

 Encapsulation makes your code easier to debug and maintain as the data members and
methods are collected together, which makes finding flaws easier as you would not have
to go back and forth in your code.

 Reusability of code. The ability of inheritance in OOP provides coders to re-use their
existing code without changing it and simply adding sub classes. When a higher level
class is further categorised in a sub class all upper class data members and methods are
also available for the lower class. This way you can accommodate ‘new’ objects that
differ slightly from the current design. This can be explained via a grocery store. Where
all ‘objects’ would have a price and a serial number, but can be furthered divided into
categories like food, utilities, stationary, etc. Therefore, by extension the categories have
some properties not shared by other categories. This concept can be applied to
software’s as well, as you can share your code without needing to make major changes.
All of the above mentioned benefits lead to more positive outcomes like increased
productivity (modular design that can be divided), easy to maintain code, high quality
software with lower costs and faster development, separates interface and implementation.

You might also like