SlideShare a Scribd company logo
1 of 45
Download to read offline
OBJECT-ORIENTED PROGRAMMING
(OOP)
Ahmad Karawash
OUTLINE
• Definitions
• Classes & Objects
• OOP concepts
• Pros & Cons
2
OBJECT-ORIENTED PROGRAMMING (OOP)
3
DEFINITION
• OOP is mainly a program design philosophy.
• Key idea: The real world can be “accurately” described as a collection of
objects that interact.
• Everything is grouped as self sustainable "objects". Hence, you gain
reusability by means of four main OOP concepts.
4
Object-Oriented Programming (OOP)
OOP 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 (such as automobiles), does not hold
any values of the object’ s attributes/properties
5
Object-Oriented Programming (OOP)
OPERATIONS/METHODS
• In OOP, programmers define not only the data type of a data structure, but
also the types 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.
6
Object-Oriented Programming (OOP)
OOP LANGUAGES
• Pure OO Languages
• Ruby, Python, Scala, JADE.
• Hybrid OO Languages
• Delphi, C++, Java, C#, VB.NET, Pascal, Visual Basic, MATLAB, Fortran, Perl,
COBOL, PHP.
7
Object-Oriented Programming (OOP)
CLASSES & OBJECTS
8
DEFINITIONS
• A class is a prototype, idea, and blueprint for creating objects.
• For example, in Java 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.
• Each copy of an object from a particular class is called an instance of the
class.
• The act of creating a new instance of a class is called instantiation.
9
Classes & Objects
CLASSES V.S. OBJECTS
• A class is a definition of objects with the same properties and the same
methods.
• An object is an instance of a class
10
Classes & Objects
TECHNICAL CONTRAST BETWEEN
OBJECTS & CLASSES
Object is a class in “runtime”
11
Classes & Objects
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, etc.
12
Classes & Objects
IN SHORT
An Object is a Class when it comes alive!
• Homo Sapien is a class, John and Jack are objects
• Animal is a class, the cat is an object
• Vehicle is a class, my neighbor's BMW is an object
• Galaxy is a class, the MilkyWay is an object
13
Classes & Objects
OBJECTS NEED TO COLLABORATE!
• Objects are useless unless they can collaborate to solve a problem.
• Each object is responsible for its own behavior and status.
• No one object can carry out every responsibility on its own.
14
Classes & Objects
HOW DO OBJECTS INTERACT WITH
EACH OTHER?
15
Classes & Objects
EXAMPLE OF OBJECT
INTERACTION
The OrderEntryForm wants Order to calculate the total CAD value for the
order.
16
Classes & Objects
OOP CONCEPTS
17
OOP FOUR MAIN CONCEPTS
Encapsulation
Inheritance
Abstraction
Polymorphism
18
OOP Concepts
OOP CONCEPTS - ENCAPSULATION
19
ENCAPSULATION DEFINITION
• Is the inclusion of property & method within a class/object in which it needs
to function properly.
• Also, enables reusability of an instant of an already implemented class within
a new class while hiding & protecting the method and properties from the
client classes.
20
OOP concepts - Encapsulation
ENCAPSULATION WITH CLASSES
• The class is kind of a container or capsule or a cell, which encapsulate the
set of 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.
21
OOP concepts - Encapsulation
ENCAPSULATION IN ACTION
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”
22
OOP concepts - Encapsulation
Date
Person
ENCAPSULATION – BENEFITS
• Ensures that structural changes remain local:
• Changing the class internals does not affect any code outside of the class
• Changing methods' implementation does not reflect the clients using them
• Encapsulation allows adding some logic when accessing client's data
• E.g. validation on modifying a property value
• Hiding implementation details reduces complexity -> easier maintenance
23
OOP concepts - Encapsulation
OOP CONCEPTS - INHERITANCE
24
INHERITANCE DEFINITION
• Term comes from inheritance of traits like 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 & methods to the subclass(es).
• Subclass – can inherit all its superclass attributes & methods besides having its
own unique attributes & methods.
25
OOP concepts - Inheritance
INHERITANCE PARENT/CHILD
• 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)
26
OOP concepts - Inheritance
INHERITANCE BENEFITS
• Expresses commonality among classes/objects
• Allows code reusability
• Highlights relationships
• Helps in code organization
27
OOP concepts - Inheritance
INHERITANCE EXAMPLE
28
OOP concepts - Inheritance
EXAMPLE: SINGLE INHERITANCE
One class inherits from another.
29
OOP concepts - Inheritance
EXAMPLE: MULTIPLE INHERITANCE
A class can inherit from several other classes.
Most modern languages don’t support multiple
inheritance!
30
OOP concepts - Inheritance
OOP CONCEPTS - ABSTRACTION
31
ABSTRACTION DEFINITION
• Abstraction is a basic representation of a concept.
• It is the process of removing characteristics from something in order to
reduce it to a 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.
32
OOP concepts - Abstraction
ABSTRACTION BENEFITS
• Abstraction allows programmers to represent complex real world in the
simplest manner.
• It represent the necessary features an object should possess without
representing the background details.
• It allow ease reusability and understanding for the design and enable
extension.
33
OOP concepts - Abstraction
ABSTRACT CLASS
• 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.
34
OOP concepts - Abstraction
TYPE OF CLASSES
Concrete Class Abstract Class
Can be instantiated directly Cannot be instantiated directly
35
OOP concepts - Abstraction
ABSTRACTION + INHERITANCE
Concrete Class
Abstract Class
Can be instantiated directly
Cannot be instantiated directly
Person
Teacher Student
DOB:
Name:
Address:
Specialization:
Academic Title:
Etc…:
DOB:
Name:
Address:
GPA:
Courses:
Etc…:
DOB
Name
Address
Can be instantiated directly
36
OOP concepts - Abstraction
ABSTRACT CLASS: INSTANCE &
OPERATION
• 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.
37
OOP concepts - Abstraction
OOP CONCEPTS - POLYMORPHISM
38
POLYMORPHISM DEFINITION
• 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.
• It is achieved by using many different techniques named method
overloading, operator overloading, and method overriding.
39
OOP concepts - Polymorphism
POLYMORPHISM TRAITS
• An object has “multiple identities”, based on its class inheritance tree
• It can be used in different ways
40
OOP concepts - Polymorphism
POLYMORPHISM METHODS
• In Java, two or more classes could each have a method called output.
• Each output method would do the right thing for the class that it was in.
• One output might display a number (output.number) in one class, whereas it
might display a name (output.text) in another class.
41
OOP concepts - Polymorphism
POLYMORPHISM + ABSTRACT
CLASS EXAMPLE
Shape
method Draw()
Circle
Circle.Draw()
Triangle
Triangle.Draw()
Square
Square.Draw()
42
OOP concepts - Polymorphism
PROS & CONS
43
OOP PROS
• Code reuse & recycling
• Improved software-development productivity
• Improved software maintainability
• Faster development
• Lower cost of development
• Higher-quality software
• Encapsulation
44
Conclusion
OOP CONS
• Steep learning curve
• Could lead to larger program sizes
• Could produce slower programs
45
Conclusion

More Related Content

What's hot

What's hot (20)

Core java complete notes - Contact at +91-814-614-5674
Core java complete notes - Contact at +91-814-614-5674Core java complete notes - Contact at +91-814-614-5674
Core java complete notes - Contact at +91-814-614-5674
 
C++ classes
C++ classesC++ classes
C++ classes
 
Basics of oops concept
Basics of oops conceptBasics of oops concept
Basics of oops concept
 
Object Oriented Programming Concepts
Object Oriented Programming ConceptsObject Oriented Programming Concepts
Object Oriented Programming Concepts
 
Object Oriented Concept
Object Oriented ConceptObject Oriented Concept
Object Oriented Concept
 
Java oops PPT
Java oops PPTJava oops PPT
Java oops PPT
 
Functions, classes & objects in c++
Functions, classes & objects in c++Functions, classes & objects in c++
Functions, classes & objects in c++
 
OOP
OOPOOP
OOP
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
Core java
Core javaCore java
Core java
 
Object oriented programming concepts
Object oriented programming conceptsObject oriented programming concepts
Object oriented programming concepts
 
OOPS features using Objective C
OOPS features using Objective COOPS features using Objective C
OOPS features using Objective C
 
Oop java
Oop javaOop java
Oop java
 
Classes, objects in JAVA
Classes, objects in JAVAClasses, objects in JAVA
Classes, objects in JAVA
 
Structure in c sharp
Structure in c sharpStructure in c sharp
Structure in c sharp
 
Chapter2 array of objects
Chapter2 array of objectsChapter2 array of objects
Chapter2 array of objects
 
Object Oriented Programming Concepts using Java
Object Oriented Programming Concepts using JavaObject Oriented Programming Concepts using Java
Object Oriented Programming Concepts using Java
 
1207028 634528828886611250
1207028 6345288288866112501207028 634528828886611250
1207028 634528828886611250
 
Introduction to OOP in Python
Introduction to OOP in PythonIntroduction to OOP in Python
Introduction to OOP in Python
 
Core Java
Core JavaCore Java
Core Java
 

Similar to Object-Oriented Programming (OOP)

Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingMoutaz Haddara
 
[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOPMuhammad Hammad Waseem
 
Java OOP’s_b8f87f30a61326f57ceb42912a73ab81.ppt
Java OOP’s_b8f87f30a61326f57ceb42912a73ab81.pptJava OOP’s_b8f87f30a61326f57ceb42912a73ab81.ppt
Java OOP’s_b8f87f30a61326f57ceb42912a73ab81.pptUMESHCHANDRA636141
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programmingRiturajJain8
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSkillwise Group
 
The View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptThe View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptBill Buchan
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oopcolleges
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisHarry Potter
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisLuis Goldster
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisYoung Alista
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisHoang Nguyen
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisFraboni Ec
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisTony Nguyen
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysisJames Wong
 

Similar to Object-Oriented Programming (OOP) (20)

OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
 
OOP Presentation.pptx
OOP Presentation.pptxOOP Presentation.pptx
OOP Presentation.pptx
 
Introduction to Object Oriented Programming
Introduction to Object Oriented ProgrammingIntroduction to Object Oriented Programming
Introduction to Object Oriented Programming
 
[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP[OOP - Lec 04,05] Basic Building Blocks of OOP
[OOP - Lec 04,05] Basic Building Blocks of OOP
 
Java OOP’s_b8f87f30a61326f57ceb42912a73ab81.ppt
Java OOP’s_b8f87f30a61326f57ceb42912a73ab81.pptJava OOP’s_b8f87f30a61326f57ceb42912a73ab81.ppt
Java OOP’s_b8f87f30a61326f57ceb42912a73ab81.ppt
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
C# by Zaheer Abbas Aghani
C# by Zaheer Abbas AghaniC# by Zaheer Abbas Aghani
C# by Zaheer Abbas Aghani
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
OOPS Concept.pptx
OOPS Concept.pptxOOPS Concept.pptx
OOPS Concept.pptx
 
SKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPTSKILLWISE - OOPS CONCEPT
SKILLWISE - OOPS CONCEPT
 
The View object orientated programming in Lotuscript
The View object orientated programming in LotuscriptThe View object orientated programming in Lotuscript
The View object orientated programming in Lotuscript
 
Introduction to oop
Introduction to oopIntroduction to oop
Introduction to oop
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
Object oriented analysis
Object oriented analysisObject oriented analysis
Object oriented analysis
 
oop.pptx
oop.pptxoop.pptx
oop.pptx
 

More from Ahmad karawash

Introduction to-data-science
Introduction to-data-scienceIntroduction to-data-science
Introduction to-data-scienceAhmad karawash
 
How to understand your data
How to understand your dataHow to understand your data
How to understand your dataAhmad karawash
 
Cloud storage with AWS
Cloud storage with AWSCloud storage with AWS
Cloud storage with AWSAhmad karawash
 
Build a custom metrics on aws cloud
Build a custom metrics on aws cloudBuild a custom metrics on aws cloud
Build a custom metrics on aws cloudAhmad karawash
 
Password hashing, salting, bycrpt
Password hashing, salting, bycrptPassword hashing, salting, bycrpt
Password hashing, salting, bycrptAhmad karawash
 
Reasoning of database consistency through description logics
Reasoning of database consistency through description logicsReasoning of database consistency through description logics
Reasoning of database consistency through description logicsAhmad karawash
 
Cloud computing and Service model
Cloud computing and Service modelCloud computing and Service model
Cloud computing and Service modelAhmad karawash
 
From use case to software architecture
From use case to software architectureFrom use case to software architecture
From use case to software architectureAhmad karawash
 

More from Ahmad karawash (10)

Introduction to-data-science
Introduction to-data-scienceIntroduction to-data-science
Introduction to-data-science
 
How to understand your data
How to understand your dataHow to understand your data
How to understand your data
 
Cloud storage with AWS
Cloud storage with AWSCloud storage with AWS
Cloud storage with AWS
 
Message queues
Message queuesMessage queues
Message queues
 
Build a custom metrics on aws cloud
Build a custom metrics on aws cloudBuild a custom metrics on aws cloud
Build a custom metrics on aws cloud
 
Password hashing, salting, bycrpt
Password hashing, salting, bycrptPassword hashing, salting, bycrpt
Password hashing, salting, bycrpt
 
Brute Force Attack
Brute Force AttackBrute Force Attack
Brute Force Attack
 
Reasoning of database consistency through description logics
Reasoning of database consistency through description logicsReasoning of database consistency through description logics
Reasoning of database consistency through description logics
 
Cloud computing and Service model
Cloud computing and Service modelCloud computing and Service model
Cloud computing and Service model
 
From use case to software architecture
From use case to software architectureFrom use case to software architecture
From use case to software architecture
 

Recently uploaded

WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...WSO2
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfonteinmasabamasaba
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Eraconfluent
 
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 

Recently uploaded (20)

WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next IntegrationWSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
WSO2CON2024 - Why Should You Consider Ballerina for Your Next Integration
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
WSO2Con2024 - From Code To Cloud: Fast Track Your Cloud Native Journey with C...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
WSO2CON 2024 - Lessons from the Field: Legacy Platforms – It's Time to Let Go...
 
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
WSO2CON 2024 - Building the API First Enterprise – Running an API Program, fr...
 
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
WSO2CON 2024 - Not Just Microservices: Rightsize Your Services!
 
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
WSO2CON 2024 - IoT Needs CIAM: The Importance of Centralized IAM in a Growing...
 
WSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration ToolingWSO2Con2024 - Low-Code Integration Tooling
WSO2Con2024 - Low-Code Integration Tooling
 
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
WSO2CON 2024 - Navigating API Complexity: REST, GraphQL, gRPC, Websocket, Web...
 
WSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - KanchanaWSO2Con2024 - Hello Choreo Presentation - Kanchana
WSO2Con2024 - Hello Choreo Presentation - Kanchana
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
WSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid EnvironmentsWSO2Con2024 - Software Delivery in Hybrid Environments
WSO2Con2024 - Software Delivery in Hybrid Environments
 
Evolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI EraEvolving Data Governance for the Real-time Streaming and AI Era
Evolving Data Governance for the Real-time Streaming and AI Era
 
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and ApplicationsWSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
WSO2CON 2024 - Architecting AI in the Enterprise: APIs and Applications
 
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million PeopleWSO2Con2024 - Unleashing the Financial Potential of 13 Million People
WSO2Con2024 - Unleashing the Financial Potential of 13 Million People
 
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public AdministrationWSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
WSO2CON 2024 - How CSI Piemonte Is Apifying the Public Administration
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
WSO2CON 2024 - WSO2's Digital Transformation Journey with Choreo: A Platforml...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 

Object-Oriented Programming (OOP)

  • 2. OUTLINE • Definitions • Classes & Objects • OOP concepts • Pros & Cons 2
  • 4. DEFINITION • OOP is mainly a program design philosophy. • Key idea: The real world can be “accurately” described as a collection of objects that interact. • Everything is grouped as self sustainable "objects". Hence, you gain reusability by means of four main OOP concepts. 4 Object-Oriented Programming (OOP)
  • 5. OOP 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 (such as automobiles), does not hold any values of the object’ s attributes/properties 5 Object-Oriented Programming (OOP)
  • 6. OPERATIONS/METHODS • In OOP, programmers define not only the data type of a data structure, but also the types 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. 6 Object-Oriented Programming (OOP)
  • 7. OOP LANGUAGES • Pure OO Languages • Ruby, Python, Scala, JADE. • Hybrid OO Languages • Delphi, C++, Java, C#, VB.NET, Pascal, Visual Basic, MATLAB, Fortran, Perl, COBOL, PHP. 7 Object-Oriented Programming (OOP)
  • 9. DEFINITIONS • A class is a prototype, idea, and blueprint for creating objects. • For example, in Java 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. • Each copy of an object from a particular class is called an instance of the class. • The act of creating a new instance of a class is called instantiation. 9 Classes & Objects
  • 10. CLASSES V.S. OBJECTS • A class is a definition of objects with the same properties and the same methods. • An object is an instance of a class 10 Classes & Objects
  • 11. TECHNICAL CONTRAST BETWEEN OBJECTS & CLASSES Object is a class in “runtime” 11 Classes & Objects
  • 12. 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, etc. 12 Classes & Objects
  • 13. IN SHORT An Object is a Class when it comes alive! • Homo Sapien is a class, John and Jack are objects • Animal is a class, the cat is an object • Vehicle is a class, my neighbor's BMW is an object • Galaxy is a class, the MilkyWay is an object 13 Classes & Objects
  • 14. OBJECTS NEED TO COLLABORATE! • Objects are useless unless they can collaborate to solve a problem. • Each object is responsible for its own behavior and status. • No one object can carry out every responsibility on its own. 14 Classes & Objects
  • 15. HOW DO OBJECTS INTERACT WITH EACH OTHER? 15 Classes & Objects
  • 16. EXAMPLE OF OBJECT INTERACTION The OrderEntryForm wants Order to calculate the total CAD value for the order. 16 Classes & Objects
  • 18. OOP FOUR MAIN CONCEPTS Encapsulation Inheritance Abstraction Polymorphism 18 OOP Concepts
  • 19. OOP CONCEPTS - ENCAPSULATION 19
  • 20. ENCAPSULATION DEFINITION • Is the inclusion of property & method within a class/object in which it needs to function properly. • Also, enables reusability of an instant of an already implemented class within a new class while hiding & protecting the method and properties from the client classes. 20 OOP concepts - Encapsulation
  • 21. ENCAPSULATION WITH CLASSES • The class is kind of a container or capsule or a cell, which encapsulate the set of 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. 21 OOP concepts - Encapsulation
  • 22. ENCAPSULATION IN ACTION 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” 22 OOP concepts - Encapsulation Date Person
  • 23. ENCAPSULATION – BENEFITS • Ensures that structural changes remain local: • Changing the class internals does not affect any code outside of the class • Changing methods' implementation does not reflect the clients using them • Encapsulation allows adding some logic when accessing client's data • E.g. validation on modifying a property value • Hiding implementation details reduces complexity -> easier maintenance 23 OOP concepts - Encapsulation
  • 24. OOP CONCEPTS - INHERITANCE 24
  • 25. INHERITANCE DEFINITION • Term comes from inheritance of traits like 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 & methods to the subclass(es). • Subclass – can inherit all its superclass attributes & methods besides having its own unique attributes & methods. 25 OOP concepts - Inheritance
  • 26. INHERITANCE PARENT/CHILD • 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) 26 OOP concepts - Inheritance
  • 27. INHERITANCE BENEFITS • Expresses commonality among classes/objects • Allows code reusability • Highlights relationships • Helps in code organization 27 OOP concepts - Inheritance
  • 29. EXAMPLE: SINGLE INHERITANCE One class inherits from another. 29 OOP concepts - Inheritance
  • 30. EXAMPLE: MULTIPLE INHERITANCE A class can inherit from several other classes. Most modern languages don’t support multiple inheritance! 30 OOP concepts - Inheritance
  • 31. OOP CONCEPTS - ABSTRACTION 31
  • 32. ABSTRACTION DEFINITION • Abstraction is a basic representation of a concept. • It is the process of removing characteristics from something in order to reduce it to a 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. 32 OOP concepts - Abstraction
  • 33. ABSTRACTION BENEFITS • Abstraction allows programmers to represent complex real world in the simplest manner. • It represent the necessary features an object should possess without representing the background details. • It allow ease reusability and understanding for the design and enable extension. 33 OOP concepts - Abstraction
  • 34. ABSTRACT CLASS • 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. 34 OOP concepts - Abstraction
  • 35. TYPE OF CLASSES Concrete Class Abstract Class Can be instantiated directly Cannot be instantiated directly 35 OOP concepts - Abstraction
  • 36. ABSTRACTION + INHERITANCE Concrete Class Abstract Class Can be instantiated directly Cannot be instantiated directly Person Teacher Student DOB: Name: Address: Specialization: Academic Title: Etc…: DOB: Name: Address: GPA: Courses: Etc…: DOB Name Address Can be instantiated directly 36 OOP concepts - Abstraction
  • 37. ABSTRACT CLASS: INSTANCE & OPERATION • 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. 37 OOP concepts - Abstraction
  • 38. OOP CONCEPTS - POLYMORPHISM 38
  • 39. POLYMORPHISM DEFINITION • 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. • It is achieved by using many different techniques named method overloading, operator overloading, and method overriding. 39 OOP concepts - Polymorphism
  • 40. POLYMORPHISM TRAITS • An object has “multiple identities”, based on its class inheritance tree • It can be used in different ways 40 OOP concepts - Polymorphism
  • 41. POLYMORPHISM METHODS • In Java, two or more classes could each have a method called output. • Each output method would do the right thing for the class that it was in. • One output might display a number (output.number) in one class, whereas it might display a name (output.text) in another class. 41 OOP concepts - Polymorphism
  • 42. POLYMORPHISM + ABSTRACT CLASS EXAMPLE Shape method Draw() Circle Circle.Draw() Triangle Triangle.Draw() Square Square.Draw() 42 OOP concepts - Polymorphism
  • 44. OOP PROS • Code reuse & recycling • Improved software-development productivity • Improved software maintainability • Faster development • Lower cost of development • Higher-quality software • Encapsulation 44 Conclusion
  • 45. OOP CONS • Steep learning curve • Could lead to larger program sizes • Could produce slower programs 45 Conclusion