SlideShare a Scribd company logo
OOP
OBJECT-ORIENTED PROGRAMMING
• OOP is mainly a program design philosophy.
• OOP uses a different set of programming languages than old
procedural programming languages (C, Pascal, etc..,)
• Everything in OOP is grouped as self sustainable “objects”.
• Hence, you gain re-usability by means of four main object-
oriented programming concepts.
• In OOP programmers define not only the data type of data
structure, but also the type of operations/methods(functions)
that can be applied to the data structure.
• In this way, the data structure becomes an object that includes
both data and functions (methods) in one unit. In addition,
programmers can create relationships between one object and
another.
• For example, Objects can inherit characteristics from other
objects.
Key idea in object-oriented:
The real world can be “accurately” described as a collection of
objects that interact.
Basic Terminology:
Object
usually a person, place or thing ( a noun)
Method
an action performed by an object (a verb)
Property or attribute
Characteristics of certain object.
Class
a category of similar objects, does not hold any values of the
object’s attributes/properties
Classes and Objects
• A class is a prototype, idea, and blueprint for creating objects.
• An object is an instance of a class
• For example, in C++ we define classes, which in turn are
used to create objects
• A class has a constructor for creating objects
• Class is composed of three things: its name,
attributes/properties, and methods.
Class
Objects:
Instances of the class
Class Properties:
Belong to the class
Instance Properties:
Belong to the object
Methods:
Functions of class
Class:
A class is a definition of
objects with the same
properties and the same
methods
class Bicycle {
int speed = 0;
int gear = 1;
void changeGear (int newValue) {
gear = newValue;
}
void speedUp (int increment) {
speed = speed + increment;
}
void applyBreakes (int decrement) {
speed = speed – decrement;
}
Account
Owner
Balance
Account Number
Transaction Log
Deposit Account
Interest Rate
Current Account
Over Draft Limit
Example:
Almost everything in the world can be represented as an Object
• A flower, a tree, an animal
• A student, a professor
• A desk, a chair, a classroom, a building
• A university, a city, a country
• The world, the universe
• A subject such as CS, IS, Math, History
• An information system, financial, legal, etc…,
What is an Object?
An object is an instance of a class.
Informally, an object represents an entity, either physical, conceptual, or
software.
Physical entity
truck
Conceptual entity
chemical process
Software entity
linked list
Formal definition of an “Object”
An Object is a computational entity that:
• Encapsulates some state
• Is able to perform actions, or methods, on this state
• Communicates with other objects via message passing
Classes & Objects
“X” CAR
Property
Plate No :
AD47483
Color : Blue
Manufacturer :
Mercedes
Model : Classic
Gear Type :
Automatic
Method
Moves forward
Moves backward
Moves right
Moves left
Stops
Time
Hour
Minute
void addMinutes( int m )
inTime
Attributes:
Hour = 8
Minute = 30
Methods:
void addMinutes( int m
)
Class
inTime
Attributes:
Hour = 8
Minute = 30
Methods:
void addMinutes( int m
)
Objects
• Each copy of an object from a particular class is called an instance of the class
• The act of creating a new instance of an class is called instantiation .
Class Object
Class is a data type Object is an instance of class
It generates OBJECTS It gives life to CLASS
Does not occupy memory location It occupies memory locatio
It cannot manipulated because it is not
available in memory
It can be manipulated
Encapsulation
• Is the inclusion of property and method within a class/object in
which it needs to function property.
• Also, enables reusability of an instant of an already
implemented class within a new class while hiding and
protecting the method and properties from the client classes
• The class is kind of a container or capsule or a cell, which
encapsulate the set if methods, attributes and properties to
provide its indented functionalities to other classes
• In that sense, encapsulation also allows a class to change its
internal implementation without hurting the overall functioning
of the system
• That idea of encapsulation is to hide how a class does its
operations while allowing requesting its operations
Example:
Let’s say we have a class called “Date”(day, month, year). And then
you need to define another class called “Person” that has the
following attributes (first name, last name, and birthdate). So in
this case we can instantiate an object from class “Date” inside
class “Person”
Encapsulation – Benefits
Ensures that structural changes remain local :
• Changing the class internals does not affect any code outside
of the class
• Changing method’s implementation does not reflect the clients
using them
Encapsulation allows adding some logic when accessing clients
data
• Example: validation on modifying a property value
Hiding implementation details reduces complexity
• Easier maintenance
Inheritance
• Inheritance – a way of organizing classes
• Term comes from inheritance of traits likes eye color, hair color,
and so on
• Classes with properties in common can be grouped so that their
common properties are only defined once in parent class
• Superclass – inherit its attributes and methods to the
subclass(es)
• Subclass – can inherit all its superclass attributes and methods
besides having its own unique attributes and methods
 Inheritance allows child classes to inherit the characteristics of
existing parent class
• Attributes (fields and properties)
• Operations (methods)
 Child class can extend the parent class
• Add new fields and methods
• Redefine methods (modify existing behavior)
 A class can implement an interface by providing
implementation for all its methods
Benefits:
• Expresses commonality among classes/objects
• Allows code reusability
• Highlights relationships
• Helps in code organization
Feature 1
Feature 2
Feature 1
Feature 2
------------------------
Feature 3
Base Class
Derived Class (inherited from base class)
Features of base class
Features of base class accessible to derived class
because of inheritance
Features defined in derived class
Example:
Person
------------------------------
Name : String
Address : String
Student
-----------------------
School : String
-----------------------------
Name : String
Address : String
Employee
---------------------------------
Company : String
Salary : double
---------------------------------
Name : String
Address : String
Base class
Derived class
Derived class
Vehicle
School Bus
Sports Car
Sedan Luxury Bus
Bus
Motor Cycle
Automobile
Super Class
Subclasses
Example: Single Inheritance
One class inherits from another
Account
---------------------
Balance
Name
Number
---------------------
Withdraw
Statement
Savings Currents
Superclass
(parent)
Subclass
(child)
Example: Multiple Inheritance
A class can inherit from several other classes
Flying Thing Animal
Horse
Wolf
Bird
Helicopter
Airplane
Multiple Inheritance
Abstraction:
• Abstraction is a design principle
• Is the process of removing characteristics from something in order
to reduce it to set of essential characteristics.
• Through the process of abstraction, a programmer hides all but
the relevant data about a class in order to reduce complexity and
increase reusability
• Abstraction is a basic representation of a concept
• Abstraction allows programmers to represent complex real world
in the simplest manner
• It is a process of identifying the relevant qualities and behaviors
of an object should possess, in other word represent the necessary
features without representing the background details
• You should always use abstraction to ease reusability, and
understanding for the design and enable extension
• An abstract class, which declared with the “abstract” keyword,
cannot be instantiated
• It can only be used as a super-class for other classes that extend
the abstract class.
• Abstract class is a design concept and implementation gets
completed when it is being realized by a subclass.
Abstraction – types of classes
Person
Abstract Class
Concrete Class
Teacher Student
Can be instantiated directly
DOB:
Name:
Address:
Specialization:
Academic Title:
Etc…,
DOB:
Name:
Address:
GPA:
Courses:
Etc…,
DOB:
Name:
Address:
Can be instantiated directly Can’t be instantiated directly
• An abstract class is a class that may not have any direct instances.
• An abstract operation is an operation that it is incomplete and
requires a child to supply an implementation of the operation
Shape
{abstract}
draw() {abstract}
Circle
draw()
Rectangle
draw()
 Abstract class
 Abstract operation
Polymorphism:
• Encapsulation, Inheritance, and Abstraction concepts are very
related to Polymorphism
• Polymorphisms is a generic term that means ‘many shapes’. More
precisely Polymorphisms means the ability to request that the
same methods be performed by a wide range of different types of
things
• In OOP, polymorphisms is a technical issue and principle
• It is achieved by using many different techniques named method
overloading, operator overloading, and method overriding
• An object has “multiple identities”, based on its class inheritance
tree
• It can be used in different ways
Polymorphism – Abstract class:
• It is a class that you cannot instantiate from, however, you use
it to dominate and specify how the minimum requirements in an
inherited classes should be
public abstract class Robot {
public virtual abstract void Move ( )
// abstract move needs
}
public class LeggedRobot:Robot {
public override void Move() {
//actions of legged robot to move
}
}
public class WheeledRobot:Robot {
public override void Move() {
// actions of Wheeled robot to move
}
}
public void moveRobot (Robot A) {
A.Move();
}
public moveAllRobots() {
LeggedRobot lr = new LeggedRobot();
WheeledRobot wr = new WheeledRobot();
moveRobot(lr);
moveRobot(wr);
}
Advantages of OOP
• Code reuse and recycling
• Improved software-development productivity
• Improved software maintainability
• Faster development
• Lower cost of development
• Higher-quality software
• Encapsulation
Disadvantages of OOP:
• Steep learning curve
• Could lead to larger program sizes
• Could produce slower programs

More Related Content

PDF
Object-Oriented Programming (OOP)
PPTX
object oriented programing lecture 1
PPTX
Object Oriented Programming Class and Objects
DOCX
Structural ModelingDr. Ardeshir BadrObjectives• .docx
DOC
C# by Zaheer Abbas Aghani
DOC
C# by Zaheer Abbas Aghani
PDF
O6u CS-315A OOP Lecture (1).pdf
PPTX
Advanced Topics on Database - Unit-2 AU17
Object-Oriented Programming (OOP)
object oriented programing lecture 1
Object Oriented Programming Class and Objects
Structural ModelingDr. Ardeshir BadrObjectives• .docx
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
O6u CS-315A OOP Lecture (1).pdf
Advanced Topics on Database - Unit-2 AU17

Similar to OOP Presentation.pptx (20)

PPTX
Object oriented programming
PPTX
Principles of Agile Topic. Basic understanding of Agile principles.
PPTX
Introduction to Object Oriented Programming
PPTX
PPT
Ooad ch 2
PPTX
Object oriented analysis
PPTX
Object oriented analysis
PPTX
Object oriented analysis
PPTX
Object oriented analysis
PPTX
Object oriented analysis
PPTX
Object oriented analysis
PPTX
Object oriented analysis
PPTX
Concept of Object-Oriented in C++
PPTX
Introduction to oop
PPTX
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
PDF
Introduction to C++ Class & Objects. Book Notes
PPT
C++ Programming Course
PPT
Ccourse 140618093931-phpapp02
PPTX
CPP-Unit 1.pptx
Object oriented programming
Principles of Agile Topic. Basic understanding of Agile principles.
Introduction to Object Oriented Programming
Ooad ch 2
Object oriented analysis
Object oriented analysis
Object oriented analysis
Object oriented analysis
Object oriented analysis
Object oriented analysis
Object oriented analysis
Concept of Object-Oriented in C++
Introduction to oop
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
Introduction to C++ Class & Objects. Book Notes
C++ Programming Course
Ccourse 140618093931-phpapp02
CPP-Unit 1.pptx
Ad

Recently uploaded (20)

PDF
Weekly quiz Compilation Jan -July 25.pdf
PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
Empowerment Technology for Senior High School Guide
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Computing-Curriculum for Schools in Ghana
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
Trump Administration's workforce development strategy
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Complications of Minimal Access Surgery at WLH
Weekly quiz Compilation Jan -July 25.pdf
Digestion and Absorption of Carbohydrates, Proteina and Fats
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Indian roads congress 037 - 2012 Flexible pavement
Empowerment Technology for Senior High School Guide
Practical Manual AGRO-233 Principles and Practices of Natural Farming
LDMMIA Reiki Yoga Finals Review Spring Summer
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Final Presentation General Medicine 03-08-2024.pptx
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
202450812 BayCHI UCSC-SV 20250812 v17.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Computing-Curriculum for Schools in Ghana
Supply Chain Operations Speaking Notes -ICLT Program
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
Trump Administration's workforce development strategy
Final Presentation General Medicine 03-08-2024.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
Complications of Minimal Access Surgery at WLH
Ad

OOP Presentation.pptx

  • 2. • OOP is mainly a program design philosophy. • OOP uses a different set of programming languages than old procedural programming languages (C, Pascal, etc..,) • Everything in OOP is grouped as self sustainable “objects”. • Hence, you gain re-usability by means of four main object- oriented programming concepts.
  • 3. • In OOP programmers define not only the data type of data structure, but also the type of operations/methods(functions) that can be applied to the data structure. • In this way, the data structure becomes an object that includes both data and functions (methods) in one unit. In addition, programmers can create relationships between one object and another. • For example, Objects can inherit characteristics from other objects.
  • 4. Key idea in object-oriented: The real world can be “accurately” described as a collection of objects that interact.
  • 5. Basic Terminology: Object usually a person, place or thing ( a noun) Method an action performed by an object (a verb) Property or attribute Characteristics of certain object. Class a category of similar objects, does not hold any values of the object’s attributes/properties
  • 6. Classes and Objects • A class is a prototype, idea, and blueprint for creating objects. • An object is an instance of a class • For example, in C++ we define classes, which in turn are used to create objects • A class has a constructor for creating objects • Class is composed of three things: its name, attributes/properties, and methods.
  • 7. Class Objects: Instances of the class Class Properties: Belong to the class Instance Properties: Belong to the object Methods: Functions of class
  • 8. Class: A class is a definition of objects with the same properties and the same methods class Bicycle { int speed = 0; int gear = 1; void changeGear (int newValue) { gear = newValue; } void speedUp (int increment) { speed = speed + increment; } void applyBreakes (int decrement) { speed = speed – decrement; }
  • 9. Account Owner Balance Account Number Transaction Log Deposit Account Interest Rate Current Account Over Draft Limit Example:
  • 10. Almost everything in the world can be represented as an Object • A flower, a tree, an animal • A student, a professor • A desk, a chair, a classroom, a building • A university, a city, a country • The world, the universe • A subject such as CS, IS, Math, History • An information system, financial, legal, etc…, What is an Object? An object is an instance of a class.
  • 11. Informally, an object represents an entity, either physical, conceptual, or software. Physical entity truck Conceptual entity chemical process Software entity linked list
  • 12. Formal definition of an “Object” An Object is a computational entity that: • Encapsulates some state • Is able to perform actions, or methods, on this state • Communicates with other objects via message passing
  • 13. Classes & Objects “X” CAR Property Plate No : AD47483 Color : Blue Manufacturer : Mercedes Model : Classic Gear Type : Automatic Method Moves forward Moves backward Moves right Moves left Stops
  • 14. Time Hour Minute void addMinutes( int m ) inTime Attributes: Hour = 8 Minute = 30 Methods: void addMinutes( int m ) Class inTime Attributes: Hour = 8 Minute = 30 Methods: void addMinutes( int m ) Objects
  • 15. • Each copy of an object from a particular class is called an instance of the class • The act of creating a new instance of an class is called instantiation . Class Object Class is a data type Object is an instance of class It generates OBJECTS It gives life to CLASS Does not occupy memory location It occupies memory locatio It cannot manipulated because it is not available in memory It can be manipulated
  • 17. • Is the inclusion of property and method within a class/object in which it needs to function property. • Also, enables reusability of an instant of an already implemented class within a new class while hiding and protecting the method and properties from the client classes • The class is kind of a container or capsule or a cell, which encapsulate the set if methods, attributes and properties to provide its indented functionalities to other classes • In that sense, encapsulation also allows a class to change its internal implementation without hurting the overall functioning of the system • That idea of encapsulation is to hide how a class does its operations while allowing requesting its operations
  • 18. Example: Let’s say we have a class called “Date”(day, month, year). And then you need to define another class called “Person” that has the following attributes (first name, last name, and birthdate). So in this case we can instantiate an object from class “Date” inside class “Person”
  • 19. Encapsulation – Benefits Ensures that structural changes remain local : • Changing the class internals does not affect any code outside of the class • Changing method’s implementation does not reflect the clients using them Encapsulation allows adding some logic when accessing clients data • Example: validation on modifying a property value Hiding implementation details reduces complexity • Easier maintenance
  • 21. • Inheritance – a way of organizing classes • Term comes from inheritance of traits likes eye color, hair color, and so on • Classes with properties in common can be grouped so that their common properties are only defined once in parent class • Superclass – inherit its attributes and methods to the subclass(es) • Subclass – can inherit all its superclass attributes and methods besides having its own unique attributes and methods
  • 22.  Inheritance allows child classes to inherit the characteristics of existing parent class • Attributes (fields and properties) • Operations (methods)  Child class can extend the parent class • Add new fields and methods • Redefine methods (modify existing behavior)  A class can implement an interface by providing implementation for all its methods
  • 23. Benefits: • Expresses commonality among classes/objects • Allows code reusability • Highlights relationships • Helps in code organization
  • 24. Feature 1 Feature 2 Feature 1 Feature 2 ------------------------ Feature 3 Base Class Derived Class (inherited from base class) Features of base class Features of base class accessible to derived class because of inheritance Features defined in derived class
  • 25. Example: Person ------------------------------ Name : String Address : String Student ----------------------- School : String ----------------------------- Name : String Address : String Employee --------------------------------- Company : String Salary : double --------------------------------- Name : String Address : String Base class Derived class Derived class
  • 26. Vehicle School Bus Sports Car Sedan Luxury Bus Bus Motor Cycle Automobile Super Class Subclasses
  • 27. Example: Single Inheritance One class inherits from another Account --------------------- Balance Name Number --------------------- Withdraw Statement Savings Currents Superclass (parent) Subclass (child)
  • 28. Example: Multiple Inheritance A class can inherit from several other classes Flying Thing Animal Horse Wolf Bird Helicopter Airplane Multiple Inheritance
  • 29. Abstraction: • Abstraction is a design principle • Is the process of removing characteristics from something in order to reduce it to set of essential characteristics. • Through the process of abstraction, a programmer hides all but the relevant data about a class in order to reduce complexity and increase reusability • Abstraction is a basic representation of a concept
  • 30. • Abstraction allows programmers to represent complex real world in the simplest manner • It is a process of identifying the relevant qualities and behaviors of an object should possess, in other word represent the necessary features without representing the background details • You should always use abstraction to ease reusability, and understanding for the design and enable extension
  • 31. • An abstract class, which declared with the “abstract” keyword, cannot be instantiated • It can only be used as a super-class for other classes that extend the abstract class. • Abstract class is a design concept and implementation gets completed when it is being realized by a subclass.
  • 32. Abstraction – types of classes Person Abstract Class Concrete Class Teacher Student Can be instantiated directly DOB: Name: Address: Specialization: Academic Title: Etc…, DOB: Name: Address: GPA: Courses: Etc…, DOB: Name: Address: Can be instantiated directly Can’t be instantiated directly
  • 33. • An abstract class is a class that may not have any direct instances. • An abstract operation is an operation that it is incomplete and requires a child to supply an implementation of the operation Shape {abstract} draw() {abstract} Circle draw() Rectangle draw()  Abstract class  Abstract operation
  • 34. Polymorphism: • Encapsulation, Inheritance, and Abstraction concepts are very related to Polymorphism • Polymorphisms is a generic term that means ‘many shapes’. More precisely Polymorphisms means the ability to request that the same methods be performed by a wide range of different types of things • In OOP, polymorphisms is a technical issue and principle • It is achieved by using many different techniques named method overloading, operator overloading, and method overriding
  • 35. • An object has “multiple identities”, based on its class inheritance tree • It can be used in different ways Polymorphism – Abstract class: • It is a class that you cannot instantiate from, however, you use it to dominate and specify how the minimum requirements in an inherited classes should be
  • 36. public abstract class Robot { public virtual abstract void Move ( ) // abstract move needs } public class LeggedRobot:Robot { public override void Move() { //actions of legged robot to move } } public class WheeledRobot:Robot { public override void Move() { // actions of Wheeled robot to move } } public void moveRobot (Robot A) { A.Move(); } public moveAllRobots() { LeggedRobot lr = new LeggedRobot(); WheeledRobot wr = new WheeledRobot(); moveRobot(lr); moveRobot(wr); }
  • 37. Advantages of OOP • Code reuse and recycling • Improved software-development productivity • Improved software maintainability • Faster development • Lower cost of development • Higher-quality software • Encapsulation
  • 38. Disadvantages of OOP: • Steep learning curve • Could lead to larger program sizes • Could produce slower programs