principle of oop’s in cpp

38
PRINCIPLE OF OOP’S Chap 1 06/17/2022 1 By:-Gourav Kottawar By:-Gourav Kottawar

Upload: gourav-kottawar

Post on 13-Jan-2017

175 views

Category:

Education


0 download

TRANSCRIPT

Page 1: principle of oop’s in cpp

05/01/2023

By:-Gourav Kottawar 1

PRINCIPLE OF OOP’SChap 1 By:-Gourav Kottawar

Page 2: principle of oop’s in cpp

05/01/2023By:-Gourav Kottawar

2

Contents 1.1 Introduction 1.2 Procedural Vs Object Oriented

Programming 1.3 Classes, Object, Data Abstraction, 1.4 Encapsulation, Inheritance, Polymorphism 1.5 Dynamic Binding, Message Passing 1.6 Object Oriented Languages 1.7 Object Based languages % - 5

Page 3: principle of oop’s in cpp

05/01/2023By:-Gourav Kottawar

3

1.1 Introduction C is a programming language developed in the

1970's alongside the UNIX operating system. C provides a comprehensive set of features for

handling a wide variety of applications, such as systems development and scientific computation.

C++ is an “extension” of the C language, in that most C programs are also C++ programs.

C++, as opposed to C, supports “object-oriented programming.”

Page 4: principle of oop’s in cpp

By:-Gourav Kottawar

Principles of Object oriented programming

05/01/2023

4

Software Crisis1. Real life problems2. designing system with open

interface3. Reusability and extensibility4. quality5. Time schedule6. Industrialize SDP.

Page 5: principle of oop’s in cpp

By:-Gourav Kottawar

Layers of computer software

05/01/2023

5

Object Oriented

Programming

1.0

Page 6: principle of oop’s in cpp

By:-Gourav Kottawar

Typical structure of Procedure oriented programming

05/01/2023

6

Page 7: principle of oop’s in cpp

05/01/2023By:-Gourav Kottawar

7

1.2 Procedural Vs Object Oriented Programming Procedure Oriented Programming

Object Oriented Programming

Divided Into In POP, program is divided into small parts called functions.

In OOP, program is divided into parts called objects.

Importance

In POP,Importance is not given to data but to functions as well as sequence of actions to be done.

In OOP, Importance is given to the data rather than procedures or functions because it works as areal world.

Approach POP follows Top Down approach. OOP follows Bottom Up approach.

Access Specifiers POP does not have any

access specifier.OOP has access specifiers named Public, Private, Protected, etc.

Data MovingIn POP, Data can move freely from function to function in the system.

In OOP, objects can move and communicate with each other through member functions.

Page 8: principle of oop’s in cpp

05/01/2023By:-Gourav Kottawar

8

1.2 Procedural Vs Object Oriented Programming

Procedure Oriented Programming

Object Oriented Programming

Expansion To add new data and function in POP is not so easy.

OOP provides an easy way to add new data and function.

Data Access

In POP, Most function uses Global data for sharing that can be accessed freely from function to function in the system.

In OOP, data can not move easily from function to function,it can be kept public or private so we can control the access of data.

Data HidingPOP does not have any proper way for hiding data so it is less secure.

OOP provides Data Hiding so provides more security.

Overloading In POP, Overloading is not possible.

In OOP, overloading is possible in the form of Function Overloading and Operator Overloading.

Examples Example of POP are : C, VB, FORTRAN, Pascal.

Example of OOP are : C++, JAVA, VB.NET, C#.NET.

Page 9: principle of oop’s in cpp

05/01/2023By:-Gourav Kottawar

9

Object Oriented paradigm Emphasis is data rather than procedure. Programs are divided into what are known as objects. Data structures are designed such that they characterize

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. Objects may communicate with each other through

functions. New data and functions can be easily added whenever

necessary. Follows bottom up approach

Page 10: principle of oop’s in cpp

05/01/2023By:-Gourav Kottawar

10

Organization of data and functions in oop

Page 11: principle of oop’s in cpp

By:-Gourav Kottawar

Basic concepts of object oriented programming

05/01/2023

11

Objectobjects are runtime entities in an

object oriented system.An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.

Page 12: principle of oop’s in cpp

By:-Gourav Kottawar

objects

05/01/2023

12

Numbers

Page 13: principle of oop’s in cpp

By:-Gourav Kottawar

objects

05/01/2023

13

Text

Page 14: principle of oop’s in cpp

By:-Gourav Kottawar

objects

05/01/2023

14

Pictures

Page 15: principle of oop’s in cpp

By:-Gourav Kottawar

objects

05/01/2023

15

Sound

Page 16: principle of oop’s in cpp

By:-Gourav Kottawar

objects

05/01/2023

16

Video

Page 17: principle of oop’s in cpp

05/01/2023

Object-Oriented Programming

An object can be something in the physical world or even just an abstract idea.

An airplane, for example, is a physical object that can be manipulated by a computer.

17

Page 18: principle of oop’s in cpp

05/01/2023

Object-Oriented Programming

An object can be something in the physical world or even just an abstract idea.

A bank transaction is an example of an object that is not physical.

18

Page 19: principle of oop’s in cpp

Object-Oriented Programming

To a computer, an object is simply something that can be represented by data in the computer’s memory and manipulated by computer programs.

05/01/2023 19

Page 20: principle of oop’s in cpp

Object-Oriented Programming

The data that represent the object are organized into a set of properties.

The values stored in an object’s properties at any one time form the state of an object.

Name: PA 3794Owner: US AirlinesLocation: 39 52′ 06″ N  75 13′ 52″ W Heading: 271°Altitude: 19 mAirSpeed: 0Make: BoeingModel: 737Weight:32,820 kg

05/01/2023 20

Page 21: principle of oop’s in cpp

By:-Gourav Kottawar 05/01/2023

21

Two ways of representing an object

Page 22: principle of oop’s in cpp

By:-Gourav Kottawar

Classes

05/01/2023

22

The entire set of data and code of an object can be made a user defined data type with the help of a class.

Objects are variables of the type class. Once a class has been defined, we can

create any number of objects belonging to that class.

A class in collection of similar type objects.

Page 23: principle of oop’s in cpp

Object-Oriented Programming

Each copy of an object from a particular class is called an instance of the object.

05/01/2023 23

Page 24: principle of oop’s in cpp

Object-Oriented Programming

The act of creating a new instance of an object is called instantiation.

05/01/2023 24

Page 25: principle of oop’s in cpp

Object-Oriented Programming

A class can be thought of as a blueprint for instances of an object.

05/01/2023 25

Page 26: principle of oop’s in cpp

Object-Oriented Programming

Two different instances of the same class will have the same properties, but different values stored in those properties.

05/01/2023 26

Page 27: principle of oop’s in cpp

05/01/2023By:-Gourav Kottawar

Encapsulation27

The wrapping up of data and function into a single unit (called class) is known as encapsulation.

Data and encapsulation is the most striking feature of a class.

The data is not accessible to the outside world, and only those functions which are wrapped in the class can access it.

These functions provide the interface between the object’s data and the program.

This insulation of the data from direct access by the program is called data hiding or information hiding.

Page 28: principle of oop’s in cpp

By:-Gourav Kottawar

Abstraction

05/01/2023

28 Abstraction refers to the act of representing essential features without including the

background details or explanation. Classes use the concept of abstraction and are defined

as a list of abstract attributes such as size, wait, and cost, and function operate on these

attributes. They encapsulate all the essential properties of the object that are to be created. The attributes are some time called data members because they hold information. The

functions that operate on these data are sometimes called methods or member function

Page 29: principle of oop’s in cpp

By:-Gourav Kottawar

Abstraction

05/01/2023

29

Page 30: principle of oop’s in cpp

By:-Gourav Kottawar

Inheritance

05/01/2023

30

Inheritance is the process by which objects of one class acquired the properties of objects of another classes.

It supports the concept of hierarchical classification.

Page 31: principle of oop’s in cpp

By:-Gourav Kottawar

Polymorphism

05/01/2023

31

Polymorphism is another important OOP concept. Polymorphism, a Greek term, means the ability to take more than on form.

An operation may exhibit different behavior is different instances. The behavior depends upon the types of data used in the operation.

For example, consider the operation of addition. For two numbers, the operation will generate a sum. If the operands are strings, then the operation would

produce a third string by concatenation. The process of making an operator to exhibit different behaviors in different instances is known as operator overloading.

Page 32: principle of oop’s in cpp

By:-Gourav Kottawar 05/01/2023

32 Polymorphism plays an important role in allowing objects having different internal structures to share the same external interface.

Polymorphism is extensively used in implementing inheritance.

Page 33: principle of oop’s in cpp

By:-Gourav Kottawar

Dynamic binding

05/01/2023

33

Binding refers to the linking of a procedure call to the code to be executed in response to the call.

Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run time.

It is associated with polymorphism and inheritance.

A function call associated with a polymorphic reference depends on the dynamic type of that reference.

Page 34: principle of oop’s in cpp

By:-Gourav Kottawar

Message binding

05/01/2023

34

An object oriented program consists a set of objects that communicate with each other. The process involves- creating classes that define objects and their behavior.- creating objects from class definitions,- establishing communications among objects.

Page 35: principle of oop’s in cpp

By:-Gourav Kottawar

Benefits of oops

05/01/2023

35 Through inheritance, we can eliminate redundant

code extend the use of existing Classes. We can build programs from the standard

working modules that communicate with one another, rather than having to start writing the code from scratch. This leads to saving of development time and higher productivity.

• The principle of data hiding helps the programmer to build secure program that can not be invaded by code in other parts of a programs.

• It is possible to have multiple instances of an object to co-exist without any interference.

Page 36: principle of oop’s in cpp

By:-Gourav Kottawar

Benefits of oops

05/01/2023

36

• It is possible to map object in the problem domain to those in the program.

• It is easy to partition the work in a project based on objects.

• The data-centered design approach enables us to capture more detail of a model

can implemental form. • Object-oriented system can be easily upgraded from

small to large system. • Message passing techniques for communication between

objects makes to interface descriptions with external systems much simpler. • Software complexity can be easily managed

Page 37: principle of oop’s in cpp

05/01/2023By:-Gourav Kottawar

37

Objects Oriented languages ABAP Ada

95 Amiga

E BETA Blue Boo C++ C# Chapel Clario

n CLU COBO

L

FalconFancyFortran 2003FPrFreeBASICF-ScriptF#GambasGraphtalkIDLscriptJJ#JADEJava

GroovyJoin JavaX10

LassoLavaLexicoLingoLISPLogtalkMATLABModula-2

Modula-3

NemerleNetRexxNoopOberon (Oberon-1)

Oberon-2

Object Pascal

DelphiFree PascalTurbo Pascal

Object REXXObjective-COCaml

CobraColdFusionCommon LispCOOLCorbaScriptCurlDDylanEEiffel SatherOmnis StudioOz

Mozart Programming System

Perl since v5PHP5

Power BuilderPrototype-based languages

Actor-Based Concurrent Languages: ABCL/1, ABCL/R, ABCL/R2, ABCL/c+AgoraCecilCel

Page 38: principle of oop’s in cpp

05/01/2023

38

Object based languages

Examples of a language that is object-based but not object-oriented are early versions of Ada, Javascript, and Visual Basic (VB). These languages all support the definition of an object as a data structure but lack polymorphism and inheritance.

By:-Gourav Kottawar