0% found this document useful (0 votes)
43 views54 pages

2 - OOP Sheetal Mam.............

Uploaded by

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

2 - OOP Sheetal Mam.............

Uploaded by

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

CHARUTAR VIDYA MANDAL UNIVERSITY

A D PATEL I NSTITUTE OF TECHNOLOGY

Concepts of OOP- Chapter - 2


c wan
ta l Ma
h e e
S
Prof

PREPARED BY: PROF.


Sheetal Macwan
CP DEPARTMENT

Compiled by: Prof Sheetal Macwan


Syllabus: Ch-2
Concepts of OOP:
Introduction OOP,
Procedural Vs. Object OrientedanProgramming,
a cw
Principles of OOP, h e eta l M
of S
r
Benefits and applications of OOP
P

Compiled by: Prof Sheetal Macwan


Introduction

c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Procedural Oriented Programming
MAIN PROGRAM GLOBAL DATA

c wan
FUNCTION 1 FUNCTION l 2a
M FUNCTION 3
e eta
f Sh
Pro

Division into functions

FUNCTION 4 FUNCTION 5

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Why OOP?

Save development time (and cost) by reusing


code
once an object class is created it can be used in
other applications
Easier debugging
classes can be tested independently
reused objects have already been tested

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


OBJECT ORIENTED PROGRAMMING

Object 2
Object 1

Data c wan Data


ta l Ma
h e e
Function S Function
Prof

Object 3

Data

Function

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


OBJECT ORIENTED PROGRAMMING

Objects have both data and methods


Objects of the same class have the same data elements and methods
Objects send and receive messages
c wan to invoke actions
a l M
eeta
Sh
Prof
Key idea in object-oriented:

The real world can be accurately described as a collection of objects that


interact.

Compiled by: Prof Sheetal Macwan


Object-oriented programming
• OOP defines classes to represent “Class Car”
these things.
• Classes can contain data public interface
and methods (internal functions). a c wan
l M
eeta internal
• Classes control access Shto
Prof
data and methods. A public
interface is used by external code
when using the class.
• This is a highly effective way of
modeling real world problems inside
of a computer program.
Compiled by: Prof Sheetal Macwan
private data and methods
Principles of OOP

Compiled by: Prof Sheetal Macwan


Design Principles of OOP

Four main design principles of Object-Oriented


Programming(OOP):

Encapsulation
Abstraction
Polymorphism
Inheritance

Compiled by: Prof Sheetal Macwan


Encapsulation

c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Encapsulation

Also known as data hiding


Only object’s methods can modify information in the
wan
object. l Ma
c
e eta
Sh
Prof
Analogy:
ATM machine can only update accounts of one person
or object only.

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


SUMMARY - Encapsulation (Data Hiding)
This principle states that all important information is contained
inside an object and only selected information is exposed.

wan
The implementation and state l M aof each
c object are privately held
e eta
inside a defined class.Prof Sh

Other objects do not have access to this class or the authority to


make changes.
They are only able to call a list of public functions or methods.
This characteristic of data hiding provides greater program
security and avoids unintended data corruption.
Compiled by: Prof Sheetal Macwan
c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Abstraction
Focus only on the important facts about the problem at
hand to design, produce, and describe so that it can be
easily used without knowing the details of how it works.

Analogy: c wan
l M a
eetayou don’t have to know how the
When you drive aShcar,
f
Proare
gasoline and air mixed and ignited.
Instead you only have to know how to use the controls.

Draw map

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Inheritance
Inheritance—a way of organizing classes

Term comes from inheritance of traits like eye color,


hair color, and so on.
c wan
Ma
ta l
Classes with properties
Sh e e in common can be grouped so
Prof
that their common properties are only defined once.

Superclass – inherit its attributes & methods to the


subclass(es).

Subclass – can inherit all its superclass attributes &


methods besides having its own unique attributes &
methods. Compiled by: Prof Sheetal Macwan 35
c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


An Inheritance Hierarchy

Superclass
Vehicle
Subclasses an
c w
ta l Ma
e e
Automobile rof Sh Motorcycle Bus
P

Sedan Sports Car Luxury Bus School Bus

What properties does each vehicle inherit from the types


of vehicles above it in the diagram?

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Polymorphism
the same word or phrase can mean different things in
different contexts
c wan
ta l Ma
Analogy: h e e
S
Prof
In English, bank can mean side of a river or a place to
deposit money
move -

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


BENEFITS
a c wanOF OOP
ta l M
Sh ee
Prof

Compiled by: Prof Sheetal Macwan


Benefits of OOP

c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Benefits of OOP

c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Modularity. Encapsulation enables objects to be self-
contained, making troubleshooting and collaborative
development easier.
wan
Reusability. Code can ebe etal reused through inheritance,
Ma c
f Sh
meaning a team does
Pro not have to write the same code

multiple times.

Productivity. Programmers can construct new


programs quicker through the use of multiple libraries
and reusable code. Compiled by: Prof Sheetal Macwan
Easily upgradable and scalable. Programmers can
implement system functionalities independently.

Interface descriptions. Descriptions


a c wan of external
ta l M
systems are simple,
Prof Sh ee due to message passing
techniques that are used for objects communication.

Security Using encapsulation and abstraction, complex


code is hidden, software maintenance is easier and
internet protocols are protected.
Compiled by: Prof Sheetal Macwan
Flexibility. Polymorphism enables a single function to
adapt to the class it is placed in.
c wan
ta l Ma
Different objects can also pass through the same
Prof
Sh e e

interface.

Compiled by: Prof Sheetal Macwan


Areas for application of OOP

c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


c wan
ta l Ma
h e e
S
Prof

Compiled by: Prof Sheetal Macwan


Object-Oriented Programming
Languages
· Pure OO Languages a c wan
ta l M
Smalltalk,
h e e Eiffel, Actor, Java, Ruby,
f S
Pro
Scala, JADE, Emerald

· Hybrid OO Languages
C++, Objective-C, Object-Pascal

Compiled by: Prof Sheetal Macwan


Programming languages designed primarily for OOP include:
Java
Python wan
a c
C++ Sh e eta l M
Prof

Other programming languages that pair with OOP include:


Visual Basic .NET
PHP
JavaScript
Compiled by: Prof Sheetal Macwan

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy