0% found this document useful (0 votes)
3 views18 pages

Object Oriented Programming

Four principles of OOPs, Object Oriented Programming

Uploaded by

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

Object Oriented Programming

Four principles of OOPs, Object Oriented Programming

Uploaded by

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

Procedure Oriented Programming

Typical structure of procedure oriented program


Characteristics of procedure oriented programming
The characteristics of procedure oriented programming are:
• Procedural programming follows a top-down approach.
• The program is divided into blocks of codes called
functions, where each function performs a specific task.
• Procedural programs model real-world processes as
'procedures' operating on 'data'.
• The data and functions are detached from each other.
• The data moves freely in a program.
• It is easy to follow the logic of a program.
• A function can access other function's data by calling that
function.
Limitations of procedure oriented programming
The limitations of procedure oriented programming are:
• Procedural programming mainly focuses on procedures or functions.
Less attention is given to the data.
• The data and functions are separate from each other.
• Global data is freely moving and is shared among various functions.
Thus, it becomes difficult for programmers to identify and fix issues in
a program that originate due to incorrect data handling.
• Changes in data types need to be carried out manually all over the
program and in the functions using the same data type.
• Limited and difficult code reusability.
• It does not model real-world entities (e.g., car, table, bank account,
loan) very well where we as a human being, perceive everything as an
object.
• The procedural programming approach does not work well for large
and complex systems.
Characteristics of object-oriented programming

The characteristics of object-oriented programming are:


• It follows a bottom-up approach.
• The program resulting from object-oriented programming
is a collection of objects. Each object has its own data and
a set of operations.
• OOP restricts the free movement of data and the functions
that operate on it.
• A properly defined class can be reused, giving way to code
reusability.
• The concept of object-oriented programming models real-
world entities very well.
• Due to its object-oriented approach, it is extremely useful
in solving complex problems.
Limitations of object-oriented programming

Limitations of object-oriented programming:


• The size of the programs created using this
approach may become larger than the programs
written using procedure-oriented programming
approach.
• Software developed using this approach requires
a substantial amount of pre-work and planning.
• OOP code is difficult to understand if you do not
have the corresponding class documentation.
• In certain scenarios, these programs can consume
a large amount of memory.
Objects
•Any entity that has state and behaviour
is known as an object.
•For example, a chair, pen, table,
keyboard, bike, etc.
•It can be physical or logical.
•An Object can be defined as an instance
of a class.
•An object contains an address and takes
up some space in memory.
•Objects can communicate without
knowing the details of each other's data
or code. Example: A dog is an object because it
•The only necessary thing is the type of has states like colour, name, breed,
message accepted and the type of etc. as well as behaviours like wagging
response returned by the objects. the tail, barking, eating, etc.
Class

•Collection of objects is called class.


•It is a logical entity.
•A class can also be defined as a blueprint from which you can create an
individual object.
•Class doesn't consume any space.
Inheritance

•When one object acquires all the properties and behaviours of a parent object, it
is known as inheritance.
•It provides code reusability.
•It is used to achieve runtime polymorphism.
Polymorphism
•If one task is performed in different ways,
it is known as polymorphism.
•For example: to convince the customer
differently, to draw something, for
example, shape, triangle, rectangle, etc.
•In Java, we use method overloading and
method overriding to achieve
polymorphism.

Another example can be to speak something; for


example, a cat says meow, dog says woof, duck
says quack etc.
Abstraction

• Hiding internal details and showing functionality is known as


abstraction.
• For example phone call, we don't know the internal processing.
• In Java, we use abstract class and interface to achieve abstraction.
Encapsulation
•Binding (or wrapping) code and data
together into a single unit are known
as encapsulation.
•For example, a capsule, it is wrapped
with different medicines.
•A java class is the example of
encapsulation.

You might also like