Chapter 1 Principles of OOP Theory
Chapter 1 Principles of OOP Theory
You have already learnt High-Level languages those are designed by the expert
people (programmer). These languages are machine independent. We can
develop and understand program logic without having much knowledge about
Page | 1
UMESH COMPUTE KENDRA (PH: 9897188951)
the computer’s architecture. The programming style and context is easier to
learn and the entire code focuses on the specific program to be created. Every
single program written in a high-level language must be interpreted into
machine language before being executed by the computer.
BASIC, C, C++ and java are popular examples of high-level languages.
BASIC, COBOL, FORTRAN and C are commonly known as Procedure Oriented
Programming (POP). The procedure-oriented approach allows the users to
develop their logic by applying a number of functions that would enable
program productivity.
Here is a simple flow diagram is illustrated to depict the procedure
programming approach.
Page | 2
UMESH COMPUTE KENDRA (PH: 9897188951)
Characteristics of Procedure Oriented Progamming: -
• Procedural Programming follows a top-down approach.
• The program is divided into blocks of codes classed functions.
• It is easy to follow the logic of a program.
• Emphasis is on functions.
• The data is moved freely in the program.
• Functions share global data.
Limitations of Procedure Oriented Programming: -
• Procedural programming mainly focuses on procedures or functions.
Less attention is given on data.
• As data values are global to all the functions, you may require to make
necessary changes in all the functions due to any change in the data
values.
• It is not suitable to solve complex problems in real situations.
• The data and functions are detected from each others.
• Limited and difficult code reusability.
OBJECT ORIENTED PROGRAMMING (OOP):
In object-oriented programming (OOP) is an approach to standardize the
programs by creating a partitioned memory area for both data and functions.
It does not allow data to flow freely from one function to another.
In this system, the complete problem is decomposed into a number of entities
called objects. Each object includes a set of data items and related functions.
Page | 3
UMESH COMPUTE KENDRA (PH: 9897188951)
The data values of an object are applicable only within the functions
associated with that object. The resident data can never be handled by
external functions.
In this way the data are protected and secured from being troubled by eternal
sources. Thus, allowing object-oriented feature to be a powerful tool for
programming. The organization of data and function in OOP can be illustrated
as:
Page | 4
UMESH COMPUTE KENDRA (PH: 9897188951)
Limitations of Object-Oriented Programming: -
• Software developed using this approach requires a substantial amount of
pre-work and planning.
• Oops code is difficult to understand if you do not have the corresponding
class.
Differentiate between POP and OOP: -
Procedural Oriented Programming Object Oriented Programming
The stress is put on the function The stress is put on data rather than
rather than the data. the functions.
It allows data to flow freely The data is restricted to be used in a
throughout the program. specific program area.
It follows top-down programming It follows bottom-up programming
approach. approach.
Entire program is divided into Entire program is divided into
functions. objects.
Data and functions are separated. Data and functions are encapsulated
into a single entity called object.
Limited and difficult code reusability. Easy code reusability.
DEFINE
Object: - It is unique entity, which contains data and functions (characteristics
and behaviour) together in an OOP language.
Real World Object: - The object that we experience or use in our day to day
life. Each real-world object contains characteristics and behaviour. The
characteristics basically referred as parts of its body or specifications. Whereas
behaviour as the purpose of its use or its function.
Page | 5
UMESH COMPUTE KENDRA (PH: 9897188951)
Software Objects: - A software object is created through java program. When
we compare a software object to real world object then the characteristics are
referred to as data members of software objects whereas behaviour of real-
world objects are compared with member functions of software objects.
Class: - Class is a template of objects. Each object of a class possesses some
characteristics and behaviours defined within the class. Thus, class is slao
referred to as a blue print or prototype of an object.
Page | 6
UMESH COMPUTE KENDRA (PH: 9897188951)
The class gets inherited to another class is known as Base class or Super class
or Parent class. The class that inherits form a base class is known as Derived
class or Sub class or Child class.
“The term inheritance means to link and share some common properties of
one class with the other class. This can be done by extending the object of one
class into another class and using through it.”
POLYMORPHISM:
“Polymorphism is one of the Object-Oriented Programming (OOP) principles,
which supports function overloading. It is the process of using a function or
method for more than one purpose. The term function overloading is defined
as it has the same function name with different parameters.”
Thus, the function overloading is a process to create a number of functions or
methods with the same name but with different parameters.
ENCAPSULATION:
“One of the important features of Object-Oriented Programming is to restrict
the free flow of data from one object to another. The data and functions are
wrapped together in an object in such a way that the data of a particular object
can only be used in associated functions. The system of wrapping data and
functions into a single unit is known as Encapsulation.
Thus, encapsulation is helpful in an object-oriented programming in the
following ways:
1. The source code of an object could be maintained independently.
2. The object maintains privacy of the data members. However, the changes
that take place in methods don’t affect the other object.
Page | 7
UMESH COMPUTE KENDRA (PH: 9897188951)