5.1
Concept of OOP
An
approach that provides a way of modularizing programs by crating partitioned
memory area for both data and functions that can be used as templates for
creating copies of such modules on demand is called Object Oriented
Programming.
5.2
Features of OOP
OOP posses following
Characteristics / features:
a) Emphasis
is given on data rather than procedures.
b) Data
structures are designed such that they characterize the objects.
c) Functions
that operate on the data of object are tied together in the data structure.
d) Data
is hidden and cannot be accessed by external functions.
e) Objects
may communicate with each other through functions.
f) New
data and functions can be easily added whenever necessary.
g) Follows
bottom-up approach in program design.
Advantages
/ importance of OOP
·
Software complexity can be easily
managed.
·
Easy to upgrade from small to large
systems.
·
Data hiding helps to make more secure
programs.
·
Follows bottom: up approach in program
design.
·
It reduces the software maintenance
cost.
Disadvantages
of OOP
·
Not all languages are suitable to
implement the OOP concepts easily.
·
Suitable only in long run while managing
large software projects.
·
It is not the action-oriented.
Object
The
basic run-time entities in an object-oriented system are called object.
They
may represent a person, a place, a bank account, a table of data or any item
that the program has to handle. When a program executed, the objects interact
by sending messages to one another for example, if “customer” and “account” are
two objects in a program, then the customer object may send a message to the
account object requesting for bank balance.
Each
object contains data, and code to manipulate the data. Objects can interact
without having to know details of each other’s data on code. It is sufficient
to know the type of message accepted, and the type of response returned by the
objects.
Object: STUDENT
|
DATA:
Name
Date
of birth
Marks
--------------
|
Functions:
Total
Average
Display
------------
|
Class
A
class is a collection of objects of similar type. For example, mango, apple and
oranges are members of the class fruit. Once a class has been defined, we can
create any number of objects belonging to that class with the data of type
class with which they are created. The syntax used to create an object is no
different than the syntax object in C. For example if fruit has been defined as
a class, then the statement
fruit mango;
will
create an object mango belonging to
the class fruit.
Polymorphism
Polymorphism,
a Greek term, means the ability to take more than one form. An operation may
exhibit different instances. The behavior depends upon the types of data used
in the operation. For examples: consider the operations of addition. For two numbers (2+3=5), the operation will
generate a sum. If the operands are strings, then the operation would produce a
third strings by concentration (“IBM”+ “PC”= “IBMPC”). The process of making an
operator to exhibit different behaviors in different instances is called
operator overloading.
Inheritance
Inheritance
is the process by which objects of one class acquire the properties of objects
of another class. In OOP, the concept of inheritance provides the idea of
reusability. This means that we can add additional features to an existing
class without modifying it. This is possible by deriving a new class from the
existing one. The new class will have the combined features of both the
classes. It supports the concept of hierarchical classification. For examples,
the bird “robin” is a part of the class “flying bird” which is again a part of
the class “bird”.
5.3
Application of OOP
The
promising areas for application of OOP include:
·
Real time systems.
·
Simulation and modeling.
·
Object – oriented database.
·
Image processing and patterns
recognition.
·
Computer Aided Design system.
·
AI and expert systems. Etc
5.4 Difference between
OOP and structured programming language
Object
– Oriented Programming
|
Structured
– Oriented Programming
(Procedure
oriented Programming)
|
1. It
models real world problems very well.
|
1. It
does not model real world problems very well.
|
2. Emphasis
is on doing things (algorithms).
|
2. Emphasis
is on data rather than procedure.
|
3. Programs
are divided into objects.
|
3. Programs
are divided into function.
|
4. Data
is hidden and cannot be accessed by external functions.
|
4. Data
move openly from function to functions.
|
5. Follows
bottom-up approach in program design.
|
5. Follows
top-down approach in program design.
|
6. Examples:-
C++, Java, C# etc.
|
6. Example:-
C, Pascal, FORTRAN, Q-BASIC etc.
|
Homework
questions [Unit-5]
1. What
is object – oriented programming? How it is different from the procedure
oriented programming? (2068)
2. Write
the advantages and disadvantages of OOP. (2069)
3. Why
polymorphism and inheritance are important concepts of OOP? Explain. (2058,
2068)
4. What
is procedural oriented programming? Explain. (2070)
5.
What is OOP? Define the terms
inheritance and polymorphism with examples. (2061, 62, 63, 64, 65, 67, 70 ‘D’)
Very nice article which helped me a lot! Thank you so much !
ReplyDeletePython Courses