0% found this document useful (0 votes)
11 views25 pages

Introduction to Object-Oriented Programming

The document provides an introduction to Object-Oriented Programming (OOP), contrasting it with Procedural-Oriented Programming and highlighting key concepts such as classes, objects, methods, and attributes. It explains the main principles of OOP, including abstraction, encapsulation, inheritance, and polymorphism, as well as the benefits of using OOP in software development. Additionally, it covers the phases of Object-Oriented Software Development and introduces Unified Modeling Language (UML) for visualizing system designs.

Uploaded by

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

Introduction to Object-Oriented Programming

The document provides an introduction to Object-Oriented Programming (OOP), contrasting it with Procedural-Oriented Programming and highlighting key concepts such as classes, objects, methods, and attributes. It explains the main principles of OOP, including abstraction, encapsulation, inheritance, and polymorphism, as well as the benefits of using OOP in software development. Additionally, it covers the phases of Object-Oriented Software Development and introduces Unified Modeling Language (UML) for visualizing system designs.

Uploaded by

aboodhk225
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd

Introduction to OOP

Full Stack Web Developer


Advanced Programming
FWD 122
Introduction

So far, all the codes we have written belong to the category of
Procedural-Oriented Programming, which consists of a list of
instructions to tell the computer what to do; these instructions are
then organized into functions.
The program is divided into a collection of variables, data structures,
and functions to accomplish different tasks.
Python is a multi-paradigm programming language, which means it
supports different programming approach.
Procedural-Oriented Programming

Writing programs made of functions that perform specific tasks.

Data and operations (functions) on the data are separate, and this
methodology requires sending data to functions.

Focuses on creating functions that operate on the program’s data.


Object-Oriented Programming

• Object-Oriented Programming (OOP) is a programming paradigm


(think of it as a methodology/writing style) in which you think of
everything as real-life objects.
• The OOP approach organizes programs in a way that mirrors the real
world, in which all objects are associated with both attributes and
behaviors.
• Using objects improves software reusability and makes programs
easier to develop and easier to maintain.
Object-Oriented vs Procedural-Oriented Programming
Object-Oriented Programming Procedural-Oriented Programming
It is a bottom-up approach It is a top-down approach
Program is divided into classes and objects Program is divided into functions
Easy to modify/manage Difficult to modify/manage
Object communicate by passing messages Main function calls other functions
Data is secure Data is not secure
Object-Oriented Programming
Object-Oriented Programming (OOP) involves programming using
objects.
An object represents an entity in the real world that can be distinctly
identified.
An object has a attributes and behaviors.
The attribute of an object consists of a set of data fields with their
current values.
The behavior of an object is defined by a set of methods.
Object-Oriented Programming
The first step in OOP is to collect all of the objects a programmer
wants to manipulate and identify how they relate to each other.
Once an object is known, it is labeled with a class of objects that
defines the kind of data it contains and any method that can
manipulate it.
Objects can communicate with well-defined interfaces called
messages.
The Structure of OOP
Classes are user-defined data types that act as the blueprint
(template) for individual objects, attributes and methods.
Objects are instances of a class created with specifically defined
data. Objects can correspond to real-world objects or an abstract
entity.
Methods are functions that are defined inside a class that describe
the behaviors of an object.
Attributes are defined in the class template and represent the state
of an object.
The Main Concepts of OOP
Abstraction
Encapsulation
Inheritance
Polymorphism
Abstraction
Abstraction means to focus on the essential features of an element or object
in OOP, ignoring its unnecessary properties.
The essential features are relative to the context in which the object is being
used.
Grady Booch has defined abstraction as follows − “An abstraction denotes
the essential characteristics of an object that distinguish it from all other
kinds of objects and thus provide crisply defined conceptual boundaries,
relative to the perspective of the viewer.”
Example: When a class Student is designed, the attributes
enrolment_number, name, course, and address are included while
characteristics like pulse_rate and size_of_shoe are eliminated, since they
are irrelevant in the perspective of the educational institution.
Encapsulation

The process of binding both attributes and behaviors together within


a class.
The internal details of a class can be hidden from outside.
The class has methods that provide user interfaces by which the
services provided by the class may be used.
Inheritance
The mechanism that permits new classes to be created out of existing classes
by extending and refining its capabilities.
The existing classes are called the base classes/parent classes/super-classes,
and the new classes are called the derived classes/child classes/subclasses.
The subclass can inherit or derive the attributes and methods of the super-
class(es) provided that the super-class allows so.
Besides, the subclass may add its own attributes and methods and may modify
any of the super-class methods.
Inheritance defines an “is – a” relationship.
Example: From a class Mammal, a number of classes can be derived such as
Human, Cat, Dog, Cow, etc. Humans, cats, dogs, and cows all have the distinct
characteristics of mammals. In addition, each has its own particular
characteristics. It can be said that a cow “is – a” mammal.
Types of Inheritance
Inheritance has multiple types that depend on programming
languages implementation.
Types of Inheritance
Single Inheritance – When there is only one derived class.
Multiple Inheritance – When child class is inheriting more than one
base class.
Multilevel Inheritance – When there is a level of inheritance. From
class A to class B to class C.
Hierarchical Inheritance – When more than one derived class is
inheriting one base class.
Polymorphism

Polymorphism is originally a Greek word ‘poly’ – many, ‘morph’ – forms.


So polymorphism means many forms.
Implies using operations in different ways, depending upon the instance
they are operating upon.
Allows objects with different internal structures to have a common
external interface.
Example: Let us consider two classes, Circle and Square, each with a
method findArea(). Though the name and purpose of the methods in the
classes are same, the internal implementation, i.e., the procedure of
calculating area is different for each class. When an object of class Circle
invokes its findArea() method, the operation finds the area of the circle
without any conflict with the findArea() method of the Square class.
Polymorphism

Polymorphism is of two types:


o Compile-Time Polymorphism.
o Run-time Polymorphism.

Compile-time Polymorphism: A compile-time polymorphism also


called as static polymorphism which gets resolved during the
compilation time of the program. One common example is “method
overloading”.
Run-time Polymorphism: A run-time Polymorphism is also, called as
dynamic polymorphism where it gets resolved into the run time. One
common example of Run-time polymorphism is “method overriding”.
The Benefits of OOP
Modularity. Encapsulation enables objects to be self-contained, making
troubleshooting and collaborative development easier.
Reusability. Code can be reused through inheritance, meaning a team does 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.
Easily upgradable and scalable. Programmers can implement system functionalities
independently.
Interface descriptions. Descriptions of external systems are simple, 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.
Flexibility. Polymorphism enables a single function to adapt to the class it is placed
in. Different objects can also pass through the same interface.
Phases in Object-Oriented Software Development

Object-Oriented Analysis,
Object-Oriented Design, and
Object-Oriented Implementation.
OO Analysis
 The main purpose of OO analysis is identifying the objects and
describing them correctly.
 After the objects are identified, the designing step is easily carried out.
 It is a must to identify the objects with responsibilities.
 Here the responsibility refers to the functions performed by the objects.
 Each individual object has its own functions to perform.
 The purpose of the system is fulfilled by collaborating these
responsibilities.
OO Design

This phase mainly emphasizes on meeting the requirements.


In this phase, the objects are joined together as per the intended
associations.
After the association is completed, the designing phase also gets
complete.
OO Implementation

This is the last phase that comes after the designing is done.
It implements the design using any OO languages like C++, Java,
Python, etc.
Introduction to UML
Unified Modeling Language (UML) is a general purpose modelling
language.
The main aim of UML is to define a standard way to visualize the way
a system has been designed.
It is quite similar to blueprints used in other fields of engineering.
UML is not a programming language, it is rather a visual language.
We use UML diagrams to portray the behavior and structure of a
system.
UML helps software engineers, businessmen and system architects
with modelling, design and analysis.
UML Diagrams
UML is linked with object oriented design and analysis.
UML makes the use of elements and forms associations between them
to form diagrams.
Diagrams in UML can be broadly classified as:
Structural Diagrams – Capture static aspects or structure of a system.
Structural Diagrams include: Component Diagrams, Object Diagrams, Class
Diagrams and Deployment Diagrams.
Behavior Diagrams – Capture dynamic aspects or behavior of the system.
Behavior diagrams include: Use Case Diagrams, State Diagrams, Activity
Diagrams and Interaction Diagrams.
UML Class Diagram
The most widely use UML diagram is the class diagram.
It is the building block of all object oriented software systems.
We use class diagrams to depict the static structure of a system by
showing system’s classes, their methods and attributes.
Class diagrams also help us identify relationship between different
classes or objects.
Conclusion
OOP Principle is the most widely used programming paradigm that
helps in developing large-scale applications in the real world using
the modules that allows multiple developers to work together with
such that, It can make the complete system.
The four major concepts of OOP are Abstraction, Encapsulation,
Inheritance, and Polymorphism
Many popular programming languages are using OOP paradigm,
those include Python, JavaScript, PHP, C#, Java, and many more.

You might also like