wel come praveen m jigajinni pgt (computer science)
DESCRIPTION
CHAPTER 2 OBJECT ORIENTED PROGRAMMING Created by -- Rahul Patwari (233)TRANSCRIPT
![Page 1: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/1.jpg)
WEL COME
PRAVEEN M JIGAJINNI PGT (Computer Science)
MTech[IT],MPhil (Comp.Sci), MCA, MSc[IT], PGDCA, ADCA, Dc. Sc. & Engg.email: [email protected]
![Page 2: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/2.jpg)
CHAPTER 2
OBJECT ORIENTEDPROGRAMMING
![Page 3: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/3.jpg)
3
INTRODUCTION
This chapter begins with brief discussion of various Programming paradigms that C++ supports i.e., procedural programming style, object based programming style and object oriented programming style. This is followed by detailed discussion of object oriented programming and its implementation. All this shall help you appreciate OOP style and its advantages over other programming methodologies.
![Page 4: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/4.jpg)
What is a Programming Paradigm
A Programming Paradigm defines the methodology of designing and implementing programs using the key features and building blocks of a programming language.
What is a Programming Paradigm
![Page 5: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/5.jpg)
Procedural ProgrammingProcedural programming paradigm
separates the functions and the data manipulated by them. This leads to many problems when it comes to extending the software or maintaining the software.
Procedural Programming is susceptible to design changes.
Procedural Programming leads to increase time and cost overheads during design changes.
![Page 6: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/6.jpg)
6
Object Based ProgrammingObject based programming is a newer
paradigm that implements some features of object oriented programming but not all. In object based programming, data and its associated meaningful functions are enclosed in one single entity a class. Classes enforce information hiding and abstraction thereby separating the implementation details and the uses interface.
![Page 7: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/7.jpg)
7
[For instance, you can consider a calculator, its interface would include a small display screen and a few buttons that is available to the user and implementation details i.e. how actual calculations are taking place are hidden from user.]
![Page 8: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/8.jpg)
Object based programming localizes the implementation details.
Object based programming is subject of Object Oriented programming.
![Page 9: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/9.jpg)
Advantages of Object Based Programming
i. It overcomes most shortcomings of procedural programming,
ii. It localizes changes and hides implementation details from user,
iii. It supports user-defined types,iv. Implements information hiding and
abstraction etc.
![Page 10: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/10.jpg)
Limitations
However, object based programming suffers from a major limitation and that is its inability to represent real world relationships that exist among object.For example, both car and truck are vehicles. This can not be represented in object based programming as it does not support inheritance.
![Page 11: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/11.jpg)
Object Oriented Programming
The object oriented programming paradigm is superset of object based programming. It offers all the features of object based programming and overcomes its limitation by implementing inheritance.
![Page 12: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/12.jpg)
What is an OBJECT ?Object is an identifiable entity with
some characteristics and behaviour.
What is a CLASS ?A class is a group of objects that
share common properties and relationships.
![Page 13: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/13.jpg)
Function 1
Function 2
Function 3
Data 1
Data 2
All data is openly available to all functions in the program
Properties
Behaviour
Properties
Behaviour
Object 1
Object 2
Data and functions enclosed within objects. New objects communicate with one another.
![Page 14: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/14.jpg)
BASIC CONCEPTS OF OOPThese general concepts of OOP are
given below:
Data AbstractionData
EncapsulationModularity
InheritancePolymorphism
![Page 15: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/15.jpg)
Data Abstraction
Abstraction refers to the act of representing essential features without including the background details or explanations.
![Page 16: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/16.jpg)
What is encapsulation ?
The wrapping up of data and operations / functions (that operate on the data) into a single unit (called class) is known as Encapsulation.
![Page 17: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/17.jpg)
Data
MemberFunctions
Data
MemberFunctions
Data
MemberFunctions
Object
Object Object
![Page 18: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/18.jpg)
ModularityThe act of partitioning a program into
individual components is called modularity. The justification for partitioning a program is that
• it reduces its complexity to some degree and
• it creates a number of well-defined, documented boundaries within the program
![Page 19: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/19.jpg)
What is a Modularity ?
Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.
![Page 20: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/20.jpg)
Inheritance
Inheritance is the capability of one class of things to inherit capabilities or properties from another class.
![Page 21: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/21.jpg)
Vehicles
Automobiles(Motor driven)
PulledVehicles
Car Bus Cart Rickshaw
Property Inheritance
![Page 22: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/22.jpg)
Polymorphism
Polymorphism is the ability for a message or data to be processed in more than one form.
![Page 23: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/23.jpg)
Circle
Area (circle)
Rectangle
Area (rectangle)
Shape
Area
Triangle
Area (triangle)
Polymorphism
![Page 24: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/24.jpg)
ADVANTAGES of OOP
1. Re-use of code.2. Ease of comprehension.3. Ease of fabrication and maintenance.4. Easy redesign and extension.
![Page 25: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/25.jpg)
25
DISADVANTAGES of OOP
a) With OOP, classes tend be overly generalized.b) The relations among classes become artificial
at times.c) The OOP programs’ design is tricky.d) Also one need to do proper planning and
proper design for OOP programming.e) To program with OOP, programmer need
proper skills such as design skills, programming skills, thinking in terms of objects etc.
![Page 26: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/26.jpg)
?Any Questions Please
![Page 27: WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)](https://reader035.vdocuments.us/reader035/viewer/2022062523/5a4d1af07f8b9ab05997d8dd/html5/thumbnails/27.jpg)
Thank YouVery Much