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

Concept of OOP

• Object Oriented Programming is the programming


paradigm(model)that was developed to overcome the
drawbacks and limitations of particularly procedure
oriented programming(POP).
• The term OOP originally created by Xerox PARC to
designate a computer application that describe the
methodology of using object as the foundation for
computation.
• The major need for Developing such language was to
manage the ever-increasing size and complexity of
program.
• C++, Java, C#, Visual Basic. Net, Python, Ada,
Smalltalk etc. are some popular OOP language.
Concept of OOP Contd…
• OOP allow the decomposition of problem in to
number of entity called Objects and then builds data
and function around these object.
• In OOP, Data cannot be accessed directly, they are
only accessible through member function.
• There might be the number of objects in a program
written in OOP.
• The object can be communicate with each other by
calling these respective member functions.
• OOP is the Programming paradigm in which
emphasis is given on data rather than process or
procedure.
Data and Function model in OOP
Object A Object B

Data Data

Functions Functions

Object C

Functions

Data
Concept of OOP Contd…
• OOP have taken the idea of best structured
programming and combined them with several
powerful new concept that encourage us to
perform the task of programming in a new way.
• In general, when programming in an object
oriented fashion, we break down the problem in
to sub group of related parts that takes in to
account both code and data related to each
group.
In OOP…
• Emphasis is on data rather than procedure.
• Program are divided in to objects.
• Data structures are designed such that they characterized
the objects.
• Functions that operate on the data of an object are tied
together in the data structure.
• Data is hidden and cannot be accessed by external
functions
• Object may communicate with each other through
functions.
• New data and functions can be easily added whenever
needed.
• Bottom up approach is followed in the program design.
Advantage of OOP
• We can eliminate redundant codes by using inheritance
feature of OOP.
• It is very easy for managing complex and large size
problems.
• The most important is the reusability of codes by using
the features inheritance.
• It takes very less time for the development and
maintaining the software.
• It is efficient for testing and implementation of the
system.
• It follows the bottom up approach.
• It can be implemented in the field of OODBMS,
OOAD(Object Oriented Analysis and design) and other
different fields of engineering.
Feature of OOP
Object
• An Object is any entity, things or
organization that exist in real world, which has
characteristics i.e. attribute and behavior. e.g.
Dog is an attribute an color, weight, age, types are
the attributes. Like barking wagging tails are the
behavior.
• In OOP attribute are represented by
data(variable and behaviors are represented by
function.
• An object can communicate with other by using
message passing mechanism.
Example of class car
Object car
Data
Platenumber=120
X-location=200
Y_location=400
Speed=100
Function
Move()
Park()
Accelerate()
Object contd..
• Object are the basic run time entities in an object
oriented system which may be created or destroyed at
run time.
• In OOP, Problems are divided in to a group of object
and object consist of own properties(data) and
behavior(function).
• The data and function containing in an object is called
the member data and the member function.
• The member function of an object can only access its
data.
• The basic concept behind OOP is to integrate both
data and function in to a single entity.
• This entity is also called Object.
Class
• Class is the collection of similar object.
• Defined as templates or prototype to define the
common attributes and behavior for all the object of
the class.
• The entire set of data and code of an object can be
made a user define data type with the help of a class.
• Objects are variable of type class.
• Once class has been defined, we can create any
number of objects associated with that class.
• E.g. mango, apple, and orange are the member of
class fruit.
• If fruit define as a class, then the statement fruit
mango will create an object mango belonging to the
class fruit.
Class contd..
• A class has three area public, private and
protected.
• The function and variables defined inside public
area can be accessed by any object.
• The function and variables defined inside private
area can be accessed by the object of the same
class.
• The function and variables defined inside
protected area can be accessed by the object from
the same class and derived class.
• It incorporate the concept of data hiding.
Class contd..
Student Circle

Radius
Id name Color
getRadius()
getName() getArea()
printGrade()

SocerPlayer Car

plateNumber
Name X_Location
Number Y_Location
Location Speed
run() move()
jump() park()
Kickball() aclerate
Class contd..
• Defining Class doesn’t create an object but class is
the description of object’s attributes and
behaviors.
• So no memory is allocated when the class is
created.
• When object is created then only memory is
allocated.
Data Abstraction
• Abstraction define the conceptual boundries of an
object.
• The boundaries distinguish an object from another
object.
• Abstraction is the act of representing essential
features without including the background details.
• It focus the outside view of an object, separating its
essential behavior from its implementation.
• To understand this concept more clearly, take an
example of ‘switch board’.
• We only particular switches as per our requirement
without knowing what is happening inside in detail,
that all hidden from us. This is abstraction! Where we
know essential thing to operate without knowing the
background detail happen inside it.
Encapsulation
• Encapsulation is the way of organizing data and function in to a
structure(called class) by concealing(hiding) the way the object is
implemented.
• That is preventing access to data by any means other than those specified.
• Encapsulation therefore guarantees the integrity of the data contained in the
object.
• It implies that there is visibility to the functionalities offered by an object,
and no visibility to its data.
• The best application of encapsulation is making the data field private and
using public access of functions.
• However we cannot hide an entire object.
• To use an object , a part of it need to be accessed by users.
• To provide this access, abstraction is used.
• Abstraction provides access to specific part of data while encapsulation
hides the data.
• Therefore, abstraction and encapsulation complements each other.
Inheritance
• The process of creating a new class from existing
class in which objects of the new class inherits the
attribute and behaviors of the existing class is
known as inheritance.
• The newly created class is called derive class or
child class or sub-class and the class from which
new class is created is called base class or parent
class or super class.
Types of Inheritance
1. Single Inheritance: The process of creating a new
class from an existing class is called single
inheritance that is there is only one base class
and only one derived class in single inheritance.

Base_class1

Derived_class1
Types of Inheritance
2. Multiple Inheritance: The process of creating only
one new class from several existing classes is
called multiple inheritance that is there is only
one derived class and two or more base classes in
multiple inheritance.
Base_class1 Base_class2 Base_class3

Derived_class1
Types of Inheritance
3. Hierarchical Inheritance: The process of creating
several classes from only one class is called
hierarchical inheritance that is there are two or
more derived classes and only one base class in
hierarchical inheritance.

Base_call1

Derived_call1 Derived_call2
Types of Inheritance
4. Multilevel Inheritance: The process of creating a
new class another derived class is called
multi-level inheritance.

Base_class1

Derived_class1

Derived_class2
Types of Inheritance
5. Hybrid Inheritance: It is the combination of two
or more types of Inheritance.
Polymorphism
• The term Polymorphism is formed by two Greek words:
Poly(means many) and morph(means form).
• So, the meaning of polymorphism is having many forms.
• It simply means ‘one name many form’.
• For e.g. in chemistry carbon exhibits polymorphism
because it can be found on more than one form: graphite
and diamond. Each of the form has its own distinct
properties.
• Polymorphism is important feature of OOP which refers to
the ability of an object to take on different forms
depending upon situations.
• An operation may exhibits different behavior in different
instances.
• The behavior depends up on the type of data used in the
operation.
Polymorphism
• It simplify coding and reduces the network involve
in modifying and developing an application.
• It is extensively used in implementing inheritance.
addition

add()

add(number) add(string)
General sum of two Generate third string
numbers
Polymorphism
• Operator overloading and function overloading are examples
of polymorphism in OOP.
• Let us consider the operation of addition of two numbers, the
operation will generate sum.
• If the operands are string, then the operation would produce
a third string by concatenation.
• The process of making an operator to exhibits different
behaviors in different instances is known as operator
overloading.
• Fig illustrate that the single function name can be used to
handle different number and different type of arguments.
• This is something similar to a particular word having several
different meanings depends on the context.
• Using a single function name to perform different types of
tasks is known as function overloading.
Application of OOP
• The concept of object helps to translate our
thoughts to a programs.
• It provides a way of solving a problem in the same
way as a human being perceives a real world
problem and find out the solution.
• It is possible to construct large usable components
using Object-Oriented techniques.
• Development of reusable components is rapidly
growing in commercial software industries.
• If there is complexity in software development,
OOP is the best paradigm to solve the problem.
Application of OOP
• Image processing and pattern recognition.
• Computer aided design and manufacturing.
• Object oriented database management system.
• Internet and web based applications.
• Mobile computing.
• Data warehouse and data mining.
• Digital electronics.
Difference between OOP and structure
OOP Structure
• OOP focus on representing problems using • SPL deals with organizing the
real-world objects and their behavior. program in a logical structure.
• Large programs are divided into objects. • Large programs are divided into
• It uses bottom up approach program functions.
development.
• Data and function tied together so they • It uses top down approach program
cant move freely. development.
• It consist of features such as data • Data move openly around the
abstraction, encapsulations, inheritance system from function to function.
and polymorphism.
• It doesn’t consist of those features.
• Developing program using OOP is quite
easy and less time consuming. • Developing program using SPL is
• Concept of encapsulation provide high difficult and more time consuming.
level of security. • Security can’t be maintained
• New data and functions can easily be because it has no such feature.
added whenever required. • Adding new data and function is
• The concept of inheritance provides the difficult and time consuming task.
idea of reusability that is easy to reuse
existing program code. • Code reusability is still difficult since
• Example of OOP: C++, Java, VB.net, C#, it has no proper mechanism for that.
Python, SmallTalk, Eiffel, Ada etc. • Examples of SPL are: C, Pascal,
FORTRAN, COBOL, Q-BASIC etc.

You might also like