0% found this document useful (0 votes)
6 views

01.Chapter 1 Introduction

The document provides an overview of Object-Oriented Programming (OOP) and contrasts it with Procedure-Oriented Programming (POP). It discusses fundamental concepts of OOP such as objects, classes, inheritance, polymorphism, and encapsulation, highlighting the benefits of OOP including code reusability and data security. The document serves as an educational resource for understanding the basics and advantages of OOP in programming.

Uploaded by

Maniya Daxit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

01.Chapter 1 Introduction

The document provides an overview of Object-Oriented Programming (OOP) and contrasts it with Procedure-Oriented Programming (POP). It discusses fundamental concepts of OOP such as objects, classes, inheritance, polymorphism, and encapsulation, highlighting the benefits of OOP including code reusability and data security. The document serves as an educational resource for understanding the basics and advantages of OOP in programming.

Uploaded by

Maniya Daxit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 31

(305) OBJECT ORIENTED

PROGRAMMING

CHAPTER 1- Basics
Ms. Twinkle S. Panchal
Assistant Professor
Sutex Bank College of Computer
Applications and Science, Amroli
CONTENTS

´ Introduction
´ Procedure Oriented Programming
´ Object Oriented Programming
´ POP vs OOP
´ Basic Concepts of OOP
´ Benefits of OOP

Educator: Asst Prof. Twinkle Panchal


Introduction to Programming Languages :

´ Programmers write instructions in various programming languages to perform


their computation.
´ There are 3 Types of Programming Language as follows:

Programming Language

Machine level
Language
Low Level
Language
Assembly level
Language

High level
Language
Educator: Asst Prof. Twinkle Panchal
Machine level Language :

´ Machine language is a low level language


´ Machine Language is a set of instructions executed directly by a
computer's central processing unit (CPU).
´ Each instruction performs a very specific task, such as an ALU operation on
a unit of data in a CPU register or memory.

Educator: Asst Prof. Twinkle Panchal


Assembly level Language :

´ An Assembly Language is a low-level programming language for a


computer.
´ The assembly language is designed for programming for a specific family of
processors.

Educator: Asst Prof. Twinkle Panchal


High level Language :

´ High-level language is any programming language that enables


development of a program in much simpler programming syntax
´ Generally High level language are independent of the computer's
hardware architecture.
´ High-level language focuses more on the programming logic rather than
the underlying hardware components such as memory addressing and
register utilization.

Educator: Asst Prof. Twinkle Panchal


High level Language :
´ The first high-level programming languages were designed in the 1950s.
i.e. FORTRAN (FORmula TRANslation)
´ Now there are dozens of different languages, including
´ Algol,
´ BASIC,
´ COBOL, They are high-level because they
are closer to human languages
´ C,
and far away from machine
´ C++, languages.
´ JAVA,
In contrast, assembly languages
´ FORTRAN, are considered low- level
´ Pascal, because they are very close to
machine languages.
´ Prolog.

Educator: Asst Prof. Twinkle Panchal


High level Language :

The high-level
language

Procedure oriented Object oriented


programming(POP) programming(OOP)
language. language.

Educator: Asst Prof. Twinkle Panchal


Procedure-Oriented Language

´ Procedure-oriented or function-oriented programming means function


using different functions for different tasks in a program.
´ It is a technique of combining every single task into function or procedure.
´ In the Procedure-oriented approach, the problem is viewed as sequence of
things to be done such as:
´ reading,
´ calculation and
´ printing.
´ C, VB, FORTRAN, Pascal are a few examples of POP.

Educator: Asst Prof. Twinkle Panchal


Characteristics of Procedure-oriented
Programming:

´ Emphasis is on doing things(algorithm).


´ Large programs are divided into smaller programs known as functions.
´ Most of the functions share global data.

Educator: Asst Prof. Twinkle Panchal


Characteristics of Procedure-oriented
Programming:

´ Function transforms data from one form to another.


´ It follows top-down approach in program design.

Educator: Asst Prof. Twinkle Panchal


Object Oriented
Programming
´ Object Oriented programming as an
approach that provides a way of
modularizing programs by creating
partitioned memory area for both
´ data and
´ functions.
´ This modules can be reused in future.

Educator: Asst Prof. Twinkle Panchal


OOP (Object
Oriented Programming)
´ OOP (Object Oriented Programming) allows
programmers to model real-world scenarios
using objects.
´ An object is any entity that has a State and
behaviour.
´ An Object is an instance of a class.
´ A state is called the properties, attributes or
data.
´ Behaviour is called a method.
´ Student, Lecturer, Person, Course, Book, etc.
are some examples of objects.
´ These objects communicate with other
objects by passing messages.

Educator: Asst Prof. Twinkle Panchal


Characteristics of Object-oriented
Programming
´ Emphasis is on doing rather than procedure.
´ Programs are divided into objects.
´ Data can be hidden and cannot be accessed by external/outside
functions.
´ Objects may communicate with each other through message passing.
´ New data and functions can be easily added.
´ Follows bottom-up approach in program design.

Educator: Asst Prof. Twinkle Panchal


OOP vs POP
The main difference between OOP and POP is that the OOP divides the
program into multiple objects to solve the problem while the POP divides the
program into multiple procedures or functions to solve the problem.

Difference Points OOP POP


Long Form OOP stands for Object POP stands for
Oriented Programming. Procedural Oriented
Programming.
Main Emphasis While OOP emphasis on POP emphasizes on
objects. functions.
Program Decomposition OOP divides the POP divides the program
program into multiple into multiple functions.
objects.
Modification Modification is easier in Modifications in POP can
OOP as the objects are affect the entire
independent. program.
Therefore, modifications
Educator: Asst Prof. Twinkle Panchal
are difficult in POP.
OOP VS POP
Difference Points OOP POP
Communication In OOP, the objects In POP, the functions
communicate with each communicate with each
other by passing other by passing
messages. parameters.
Data Control In OOP, each object In POP, the functions
controls its own data. share global variables.
Data Hiding It is possible to hide data There is no data hiding
mechanism
Assess Specifiers OOP has access There are no access
specifiers such as specifiers in POP.
private, protected, and
public to change the
visibility of attributes and
methods.
Educator: Asst Prof. Twinkle Panchal
OOP VS POP
Difference Points OOP POP
Code Reusability It is possible to reuse the There is no code reuse
code (by inheritance mechanism
concept)
Programming Languages C++, Java, and Python C, Pascal, FORTRAN,
are a few languages and COBAL are few
that support OOP. languages that support
POP.

Conclusion
OOP and POP are two programming paradigms.
The main difference between OOP and POP is that OOP divides the program
into multiple objects to solve the problem while POP divides the program into
multiple procedures or functions to solve the problem.

Educator: Asst Prof. Twinkle Panchal


BASIC CONCEPTS OF OBJECTS ORIENTED
PROGRAMMING

Educator: Asst Prof. Twinkle Panchal


BASIC CONCEPTS OF OBJECTS ORIENTED
PROGRAMMING

´ Objects
´ Classes
´ Data abstraction and encapsulation
´ Inheritance
´ Polymorphism
´ Dynamic binding
´ Message passing

Educator: Asst Prof. Twinkle Panchal


OBJECTS
´ Objects are the basic run-time entities in an object-oriented system.
´ Student, Lecturer, Person, Course, Book, etc. are some examples of objects.
´ The fundamental idea behind object oriented approach is to combine
both data and function into a single unit
´ These units are called objects.
´ Consider an example named Amit;
´ Amit is 25 years old and his salary is 2500. The Amit may be represented in a
computer program as an object. The data part of the object would be
(name: Amit, age: 25, salary: 2500)

Educator: Asst Prof. Twinkle Panchal


´ So, Amit is an object of Employee Class.
´ An Object with 3 attributes name, age and salary

Educator: Asst Prof. Twinkle Panchal


CLASS:
´ A group of objects that share common properties for data are collectively
called as class.
´ In C ++ a class is a new data type that contains member variables and
member functions that operate on the variables.

1) Car_Name
2) Model_number
3) Average

Educator: Asst Prof. Twinkle Panchal


Message Passing

´ An object oriented program consists of a set of objects that communicate


with each object by message passing.
´ A message for an object is a request for execution of a function.
´ Message passing involves specifying the name of the object, the name of
the function (message) and information to be sent.
Object-Name. Function(Parameter)

Stud_Object. CalculateAttendance(Subject_OOP)

Educator: Asst Prof. Twinkle Panchal


DATA ENCAPSALATION

´ The Wrapping/Combining up of data and function into a single unit (called


class) is known as Encapsulation.
´ The data is not accessible to the outside world and only those functions
which are wrapped in the class can access it.

Educator: Asst Prof. Twinkle Panchal


Data Abstraction

´ Abstraction refers to the act of representing essential features without


including the back ground details or explanations.
´ Classes use the concept of abstraction and are defined as size, width and
cost and functions to operate on the attributes.

Educator: Asst Prof. Twinkle Panchal


INHERITENCE :

´ Inheritance is the process by which objects of one class acquire the


properties of another class.
´ In the concept of inheritance provides the idea of reusability. This mean
that we can add additional features to an existing class with out modifying
it.
´ This is possible by designing a new class will have the combined features of
both the classes.

Educator: Asst Prof. Twinkle Panchal


POLYMORPHISIM:

´ Polymorphism means the ability to take more than one form.


´ An operation may exhibit different instance. The behaviour depends upon the
type of data used in the operation.
´ A language feature that allows a function or operator to be given more than
one definition.
´ The types of the arguments with which the function or operator is called
determines which definition will be used.
´ Overloading may be operator overloading or function overloading.
´ It is a#5% '( %;.)%// '2% (.%)+'*(, (0 +44*'*(, #: + /*,-5% (.%)+'%) /+: =>97 ?2%, '2*/ */
.(//*#5% :(1 use the expression x + y to denote the sum of x and y, for many
different types of x and y; integers , float and complex no. You can even define
the + operation for two strings to mean the concatenation of the strings.

Educator: Asst Prof. Twinkle Panchal


DYNAMIC BINDING :

´ Binding refers to the linking of a procedure call to the code to the


executed in response to the call. Dynamic binding means the code
associated with a given procedure call is not known untill the time of the
call at run-time. It is associated with a polymorphic reference depends
upon the dynamic type of that reference.

Educator: Asst Prof. Twinkle Panchal


Benefits of OOP

1. Through inheritance we can eliminate redundant code and extend the use
of existing classes.
2. 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. (Data Abstraction)
3. Principle of data hiding helps programmer to build secure programs that
cannot be invaded by code in other parts of the program.

Educator: Asst Prof. Twinkle Panchal


Benefits of OOP

4. It is possible to have multiple instances of an object to co-exist with out any


interference.
5. It is easy to partition the work in a project based on objects.
6. Object-oriented systems can be easily upgraded from small to large
systems.
7. Message passing techniques for communication between objects makes
the interface
8. description with external systems much simpler.
9. Software complexity can be easily managed.

Educator: Asst Prof. Twinkle Panchal


Thank you..

Educator: Asst Prof. Twinkle Panchal

You might also like