SlideShare a Scribd company logo
1 of 37
OO Basics
4/9/2024 1
Introduction to Object Orientation Topics
• Overview
• Basic Principles of Object Orientation
• Basic Concepts of Object Orientation
• Strengths of Object Orientation
4/9/2024 2
Overview
• What are object-oriented (OO) methods?
– OO methods provide a set of techniques for
analyzing, decomposing, and modularizing software
system architectures
– In general, OO methods are characterized by
structuring the system architecture on the basis of its
objects (and classes of objects) rather than the
actions it performs
• What are the benefits of OO?
– OO enhances key software quality factors of a system
and its constituent components
OO Basics 3
OOA, OOD, and OOP
• Object-oriented methods may be applied to
different phases in the software lifecycle
– e.g., analysis, design, implementation, etc.
• Object-oriented analysis (OOA) is a process of
discovery
– models and understands the requirements
of the system
• Object-oriented design (OOD) is a process of
invention and adaptation
– creates the abstractions and mechanisms
necessary to meet the system's behavioral
requirements determined during analysis
OO Basics 4
Basic Definitions OOD, and OOP
• Object-Oriented Design (OOD)
– A method for decomposing software architectures based
on the objects every system or subsystem manipulates
– Rather than "the" function it is meant to ensure
• Object-Oriented Programming (OOP)
– construction of software systems using object oriented
concepts as inheritance, polymorphism, encapsulation,
dynamic binding.
• Distinguish between OOD and OOP
– OOD is relatively independent of the programming
language used.
– OOP is primarily concerned with programming language
and software implementation issues
OO Basics 5
Object-Oriented Approach
• Model objects that are part of the problem
• Have objects exhibit their normal behavior
• Add objects that do not have problem-space
analogs
• Have the objects work together to create a
solution
Design patterns help you identify less-obvious
abstractions and the objects that can capture them.
- GOF
OO Basics 6
Five Basic Characteristics of OO
"Pure" object-orientation by Alan Kay (Smalltalk):
• Everything is an object.
• A program is a bunch of objects telling each
other what to do by sending messages.
• Each object has its own memory made up of
other objects.
• Every object has a type.
• All objects of a particular type can receive the
same message.
OO Basics 7
4/9/2024 8
Basic Principles of Object Orientation
Object Orientation
Encapsulation
Abstraction
Hierarchy
Polymorphism
What Is Abstraction?
• The essential characteristics of an entity that
distinguishes it from all other kinds of entities.
• Defines a boundary relative to the perspective of the
viewer.
• Is not a concrete manifestation, denotes the ideal
essence of something.
4/9/2024 9
Salesperson: Not
saying Which
salesperson – just a
salesperson in general!!!
Customer
Product
Manages Complexity
What Is Encapsulation?
• Hides implementation from clients.
– Clients depend on interface.
4/9/2024 10
Improves Resiliency
Encapsulation
• "Encapsulation is a mechanism used to hide the
data, internal structure, and implementation details
of an object. All interaction with the object is through
a public interface of operations." (Craig Larman)
• A boundary exists around each object;
– the boundary encapsulates the object’s characteristics
(data elements) and behaviors (functionality).
• The reason for hiding features is to:
(1) keep users from touching parts of the object
they shouldn’t touch;
(2) allows creator of the object to change the object’s internal
working without affecting the users of the object.
4/9/2024 11
What Is Polymorphism?
• The ability to hide many different
implementations behind a single interface.
4/9/2024 12
Manufacturer A
Manufacturer B
Manufacturer C
OO Principle:
Encapsulation Remote Control
Polymorphism
• Occurs with inheritance.
• Different subclasses may have different
implementations of the identical operations
• Allows you to treat an object as the base class,
rather than as a specific inherited type.
• Programmer doesn’t have to keep track of the
specific subclasses, the system selects the correct
operation based on the object type.
• Accomplished at run time using dynamic binding.
– lets you substitute objects that have identical interfaces for
each other at run-time.
4/9/2024 13
What is Hierarchy?
4/9/2024 14
Decreasing
abstraction
Increasing
abstraction
Asset
RealEstate
Savings
BankAccount
Checking Stock
Security
Bond
Elements at the same level of the hierarchy
should be at the same level of abstraction
Levels of abstraction
Basic Concepts of Object Orientation
• Object
• Class
• Attribute
• Operation
• Interface
• Package
• Relationships
4/9/2024 15
What is an Object?
• Informally, an object represents an entity, either
physical, conceptual, or software
– Physical entity
– Conceptual entity
– Software entity
4/9/2024 16
Truck
Chemical Process
Linked List
A More Formal Definition
• An object is a concept, abstraction, or thing with
sharp boundaries and meaning for an
application
• An object is something that has:
– State
– Behavior
– Identity
4/9/2024 17
What is a Class?
• A class is a description of a group of objects with
common properties (attributes), behavior
(operations), relationships, and semantics
– An object is an instance of a class
• A class is an abstraction in that it:
– Emphasizes relevant characteristics
– Suppresses other characteristics
4/9/2024 18
OO Principle: Abstraction
4/9/2024 19
Sample Class
a + b = 10
Class
Course
Properties
Name
Location
Days offered
Credit hours
Start time
End time
Behavior
Add a student
Delete a student
Get course roster
Determine if it is full
Representing Classes in the UML
• A class is represented using a rectangle with
three compartments:
– The class name
– The structure (attributes)
– The behavior (operations)
4/9/2024 20
Professor
- name
- employeeID : UniqueId
- hireDate
- status
- discipline
- maxLoad
+ submitFinalGrade()
+ acceptCourseOffering()
+ setMaxLoad()
+ takeSabbatical()
+ teachClass()
Classes of Objects
• How many classes do you see?
4/9/2024 21
Classes and Objects Relationship
• A class is an abstract definition of an object
– It defines the structure and behavior of each object in
the class
– It serves as a template for creating objects
• Objects are grouped into classes
4/9/2024 22
Objects Class
Professor Smith
Professor Jones
Professor Mellon
Professor
What Is an Attribute?
• An attribute is a named property of a class that
describes the range of values that instances of
the property may hold.
– A class may have any number of attributes or no
attributes at all.
4/9/2024 23
Attributes
Student
- name
- address
- studentID
- dateOfBirth
What Is an Operation?
• A service that can be requested from an object
to effect behavior. An operation has a signature,
which may restrict the actual parameters that are
possible.
• A class may have any number of operations or
none at all.
4/9/2024 24
Operations
Student
+ get tuition()
+ add schedule()
+ get schedule()
+ delete schedule()
+ has prerequisites()
What is an Interface?
• Interfaces formalize polymorphism
• Interfaces support “plug-and-play” architectures
4/9/2024 25
Tube
Pyramid
Cube
Shape
Draw
Move
Scale
Rotate
<<interface>>
Realization relationship (stay tuned for realization relationships)
Interface
• How do you get an object to do useful work for
you?
• Objects are known only through their interfaces
• Every object presents an interface to the world.
• Interface determines what you can get an object
to do.
• Represent a "contract" with other objects.
• Communicate with objects by sending messages
to them; an object’s interface is the set of
messages an object will respond to.
4/9/2024 26
What is a Package?
• A package is a general purpose mechanism for
organizing elements into groups
• A model element which can contain other model
elements
• Uses
– Organize the model under development
– A unit of configuration managemen
4/9/2024 27
Package Name
Relationships
• Association
– Aggregation
• Dependency
• Inheritance
• Realization
4/9/2024 28
ConsoleWindow
Window
open()
close()
move()
display()
handleEvent()
Event
DialogBox Control
association
generalization
Relationships: Association
• Models a semantic connection among classes
4/9/2024 29
Professor University
Works for
Class
Association
Association Name
Relationships: Association Aggregation
• To model a “whole/part” relationship, use
aggregation.
• Aggregation represents a “has-a” or “is a part-of”
relationship, meaning that an object of the whole
has objects of the part.
[Martin Fowler]
30
4/9/2024
Company Department
*
1
Association: Multiplicity and Navigation
• Multiplicity defines how many objects participate
in a relationships
– Specified for each end of the association
• Associations are bi-directional by default, but it is
often desirable to restrict navigation to one
direction
4/9/2024 31
Customer Account
1 0..*
Multiplicity
Navigation
Relationships: Dependency
• A relationship between two model elements where a
change in one may cause a change in the other
– E.g. Class A depends on class B: method of A manipulates
objects of B in the parameters, local variables, or return types
4/9/2024 32
Package
ClientPackage SupplierPackage
Client Supplier
Class
Dependency
relationship
Relationships: Realization
4/9/2024 33
Tube
Pyramid
Cube
Shape
Draw
Move
Scale
Rotate
<<interface>>
Realization relationship (stay tuned for realization relationships)
4/9/2024 34
Inheritance
[Martin Fowler]
Shape
origin
draw()
erase()
move()
setColor()
getColor()
Circle
draw()
erase()
Square
draw()
erase()
move()
4/9/2024 35
Polymorphism
[Martin Fowler]
Goose
move()
Penguin
move()
FlockManager
reLocate()
Bird
move()
What Gets Inherited?
• A subclass inherits its parent’s attributes,
operations, and relationships
• A subclass may:
– Add additional attributes, operations, relationships
– Redefine inherited operations (use caution!)
• Common attributes, operations, and/or
relationships are shown at the highest applicable
level in the hierarchy
4/9/2024 36
Inheritance leverages the similarities among classes
4/9/2024 37
Example: What Gets Inherited
Truck
tonnage
GroundVehicle
weight
licenseNumber
Car
owner
register( )
getTax( )
Person
0..*
Trailer
1
Superclass
(parent)
Subclass
generalization
size

More Related Content

Similar to 1a-OO-Basics.pptx lạoanfanfanfjasnfjnfkaskfklas

UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxanguraju1
 
Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "AchrafJbr
 
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaTeaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaDr. Sandeep Kumar Singh
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptxUmerUmer25
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programmingRiturajJain8
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptxYashKoli22
 
Software Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-iSoftware Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-iTaymoor Nazmy
 
Introducción al Análisis y Diseño Orientado a Objetos
Introducción al Análisis y Diseño Orientado a ObjetosIntroducción al Análisis y Diseño Orientado a Objetos
Introducción al Análisis y Diseño Orientado a ObjetosUniversidad de Occidente
 
oomd-unit-i-cgpa.ppt
oomd-unit-i-cgpa.pptoomd-unit-i-cgpa.ppt
oomd-unit-i-cgpa.pptPavan992098
 
Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Ganapathi M
 
Oo concepts and class modeling
Oo concepts and class modelingOo concepts and class modeling
Oo concepts and class modelingPreeti Mishra
 

Similar to 1a-OO-Basics.pptx lạoanfanfanfjasnfjnfkaskfklas (20)

ppt_ooad.pdf
ppt_ooad.pdfppt_ooad.pdf
ppt_ooad.pdf
 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
 
Object Modelling Technique " ooad "
Object Modelling Technique  " ooad "Object Modelling Technique  " ooad "
Object Modelling Technique " ooad "
 
OOAD chapter 1
OOAD chapter 1 OOAD chapter 1
OOAD chapter 1
 
01 chapter
01 chapter01 chapter
01 chapter
 
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,NoidaTeaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
Teaching Object Oriented Programming Courses by Sandeep K Singh JIIT,Noida
 
Ooad unit – 1 introduction
Ooad unit – 1 introductionOoad unit – 1 introduction
Ooad unit – 1 introduction
 
Ooad 2
Ooad 2Ooad 2
Ooad 2
 
Ooad
OoadOoad
Ooad
 
Introduction
IntroductionIntroduction
Introduction
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptx
 
introduction of Object oriented programming
introduction of Object oriented programmingintroduction of Object oriented programming
introduction of Object oriented programming
 
CPP-Unit 1.pptx
CPP-Unit 1.pptxCPP-Unit 1.pptx
CPP-Unit 1.pptx
 
Software Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-iSoftware Engineering Lec5 oop-uml-i
Software Engineering Lec5 oop-uml-i
 
Seng 123 8-ooad
Seng 123 8-ooadSeng 123 8-ooad
Seng 123 8-ooad
 
Introducción al Análisis y Diseño Orientado a Objetos
Introducción al Análisis y Diseño Orientado a ObjetosIntroducción al Análisis y Diseño Orientado a Objetos
Introducción al Análisis y Diseño Orientado a Objetos
 
2 uml
2 uml2 uml
2 uml
 
oomd-unit-i-cgpa.ppt
oomd-unit-i-cgpa.pptoomd-unit-i-cgpa.ppt
oomd-unit-i-cgpa.ppt
 
Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0Object oriented analysis_and_design_v2.0
Object oriented analysis_and_design_v2.0
 
Oo concepts and class modeling
Oo concepts and class modelingOo concepts and class modeling
Oo concepts and class modeling
 

Recently uploaded

Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...anilsa9823
 
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...akbard9823
 
Patrakarpuram ) Cheap Call Girls In Lucknow (Adult Only) 🧈 8923113531 𓀓 Esco...
Patrakarpuram ) Cheap Call Girls In Lucknow  (Adult Only) 🧈 8923113531 𓀓 Esco...Patrakarpuram ) Cheap Call Girls In Lucknow  (Adult Only) 🧈 8923113531 𓀓 Esco...
Patrakarpuram ) Cheap Call Girls In Lucknow (Adult Only) 🧈 8923113531 𓀓 Esco...akbard9823
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Vasant Kunj | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Vasant Kunj | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Vasant Kunj | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Vasant Kunj | Delhisoniya singh
 
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...anilsa9823
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comthephillipta
 
FULL ENJOY - 9953040155 Call Girls in Indirapuram | Delhi
FULL ENJOY - 9953040155 Call Girls in Indirapuram | DelhiFULL ENJOY - 9953040155 Call Girls in Indirapuram | Delhi
FULL ENJOY - 9953040155 Call Girls in Indirapuram | DelhiMalviyaNagarCallGirl
 
FULL ENJOY - 9953040155 Call Girls in Uttam Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Uttam Nagar | DelhiFULL ENJOY - 9953040155 Call Girls in Uttam Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Uttam Nagar | DelhiMalviyaNagarCallGirl
 
FULL ENJOY - 9953040155 Call Girls in Wazirabad | Delhi
FULL ENJOY - 9953040155 Call Girls in Wazirabad | DelhiFULL ENJOY - 9953040155 Call Girls in Wazirabad | Delhi
FULL ENJOY - 9953040155 Call Girls in Wazirabad | DelhiMalviyaNagarCallGirl
 
Editorial sephora annual report design project
Editorial sephora annual report design projectEditorial sephora annual report design project
Editorial sephora annual report design projecttbatkhuu1
 
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...akbard9823
 
The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)thephillipta
 
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKRAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKedwardsara83
 
FULL ENJOY - 9953040155 Call Girls in Shahdara | Delhi
FULL ENJOY - 9953040155 Call Girls in Shahdara | DelhiFULL ENJOY - 9953040155 Call Girls in Shahdara | Delhi
FULL ENJOY - 9953040155 Call Girls in Shahdara | DelhiMalviyaNagarCallGirl
 
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | DelhiFULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | DelhiMalviyaNagarCallGirl
 
FULL ENJOY - 9953040155 Call Girls in Kotla Mubarakpur | Delhi
FULL ENJOY - 9953040155 Call Girls in Kotla Mubarakpur | DelhiFULL ENJOY - 9953040155 Call Girls in Kotla Mubarakpur | Delhi
FULL ENJOY - 9953040155 Call Girls in Kotla Mubarakpur | DelhiMalviyaNagarCallGirl
 
Islamabad Escorts # 03080115551 # Escorts in Islamabad || Call Girls in Islam...
Islamabad Escorts # 03080115551 # Escorts in Islamabad || Call Girls in Islam...Islamabad Escorts # 03080115551 # Escorts in Islamabad || Call Girls in Islam...
Islamabad Escorts # 03080115551 # Escorts in Islamabad || Call Girls in Islam...wdefrd
 
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...anilsa9823
 
exhuma plot and synopsis from the exhuma movie.pptx
exhuma plot and synopsis from the exhuma movie.pptxexhuma plot and synopsis from the exhuma movie.pptx
exhuma plot and synopsis from the exhuma movie.pptxKurikulumPenilaian
 

Recently uploaded (20)

Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
Lucknow 💋 Call Girl in Lucknow Phone No 8923113531 Elite Escort Service Avail...
 
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
Hazratganj ] (Call Girls) in Lucknow - 450+ Call Girl Cash Payment 🧄 89231135...
 
Patrakarpuram ) Cheap Call Girls In Lucknow (Adult Only) 🧈 8923113531 𓀓 Esco...
Patrakarpuram ) Cheap Call Girls In Lucknow  (Adult Only) 🧈 8923113531 𓀓 Esco...Patrakarpuram ) Cheap Call Girls In Lucknow  (Adult Only) 🧈 8923113531 𓀓 Esco...
Patrakarpuram ) Cheap Call Girls In Lucknow (Adult Only) 🧈 8923113531 𓀓 Esco...
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Vasant Kunj | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Vasant Kunj | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Vasant Kunj | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Vasant Kunj | Delhi
 
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
Lucknow 💋 Virgin Call Girls Lucknow | Book 8923113531 Extreme Naughty Call Gi...
 
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.comBridge Fight Board by Daniel Johnson dtjohnsonart.com
Bridge Fight Board by Daniel Johnson dtjohnsonart.com
 
FULL ENJOY - 9953040155 Call Girls in Indirapuram | Delhi
FULL ENJOY - 9953040155 Call Girls in Indirapuram | DelhiFULL ENJOY - 9953040155 Call Girls in Indirapuram | Delhi
FULL ENJOY - 9953040155 Call Girls in Indirapuram | Delhi
 
FULL ENJOY - 9953040155 Call Girls in Uttam Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Uttam Nagar | DelhiFULL ENJOY - 9953040155 Call Girls in Uttam Nagar | Delhi
FULL ENJOY - 9953040155 Call Girls in Uttam Nagar | Delhi
 
FULL ENJOY - 9953040155 Call Girls in Wazirabad | Delhi
FULL ENJOY - 9953040155 Call Girls in Wazirabad | DelhiFULL ENJOY - 9953040155 Call Girls in Wazirabad | Delhi
FULL ENJOY - 9953040155 Call Girls in Wazirabad | Delhi
 
Editorial sephora annual report design project
Editorial sephora annual report design projectEditorial sephora annual report design project
Editorial sephora annual report design project
 
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
Aminabad @ Book Call Girls in Lucknow - 450+ Call Girl Cash Payment 🍵 8923113...
 
The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)The First Date by Daniel Johnson (Inspired By True Events)
The First Date by Daniel Johnson (Inspired By True Events)
 
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAKRAK Call Girls Service # 971559085003 # Call Girl Service In RAK
RAK Call Girls Service # 971559085003 # Call Girl Service In RAK
 
Dxb Call Girls # +971529501107 # Call Girls In Dxb Dubai || (UAE)
Dxb Call Girls # +971529501107 # Call Girls In Dxb Dubai || (UAE)Dxb Call Girls # +971529501107 # Call Girls In Dxb Dubai || (UAE)
Dxb Call Girls # +971529501107 # Call Girls In Dxb Dubai || (UAE)
 
FULL ENJOY - 9953040155 Call Girls in Shahdara | Delhi
FULL ENJOY - 9953040155 Call Girls in Shahdara | DelhiFULL ENJOY - 9953040155 Call Girls in Shahdara | Delhi
FULL ENJOY - 9953040155 Call Girls in Shahdara | Delhi
 
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | DelhiFULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
FULL ENJOY - 9953040155 Call Girls in Shaheen Bagh | Delhi
 
FULL ENJOY - 9953040155 Call Girls in Kotla Mubarakpur | Delhi
FULL ENJOY - 9953040155 Call Girls in Kotla Mubarakpur | DelhiFULL ENJOY - 9953040155 Call Girls in Kotla Mubarakpur | Delhi
FULL ENJOY - 9953040155 Call Girls in Kotla Mubarakpur | Delhi
 
Islamabad Escorts # 03080115551 # Escorts in Islamabad || Call Girls in Islam...
Islamabad Escorts # 03080115551 # Escorts in Islamabad || Call Girls in Islam...Islamabad Escorts # 03080115551 # Escorts in Islamabad || Call Girls in Islam...
Islamabad Escorts # 03080115551 # Escorts in Islamabad || Call Girls in Islam...
 
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
Lucknow 💋 Escorts Service Lucknow Phone No 8923113531 Elite Escort Service Av...
 
exhuma plot and synopsis from the exhuma movie.pptx
exhuma plot and synopsis from the exhuma movie.pptxexhuma plot and synopsis from the exhuma movie.pptx
exhuma plot and synopsis from the exhuma movie.pptx
 

1a-OO-Basics.pptx lạoanfanfanfjasnfjnfkaskfklas

  • 2. Introduction to Object Orientation Topics • Overview • Basic Principles of Object Orientation • Basic Concepts of Object Orientation • Strengths of Object Orientation 4/9/2024 2
  • 3. Overview • What are object-oriented (OO) methods? – OO methods provide a set of techniques for analyzing, decomposing, and modularizing software system architectures – In general, OO methods are characterized by structuring the system architecture on the basis of its objects (and classes of objects) rather than the actions it performs • What are the benefits of OO? – OO enhances key software quality factors of a system and its constituent components OO Basics 3
  • 4. OOA, OOD, and OOP • Object-oriented methods may be applied to different phases in the software lifecycle – e.g., analysis, design, implementation, etc. • Object-oriented analysis (OOA) is a process of discovery – models and understands the requirements of the system • Object-oriented design (OOD) is a process of invention and adaptation – creates the abstractions and mechanisms necessary to meet the system's behavioral requirements determined during analysis OO Basics 4
  • 5. Basic Definitions OOD, and OOP • Object-Oriented Design (OOD) – A method for decomposing software architectures based on the objects every system or subsystem manipulates – Rather than "the" function it is meant to ensure • Object-Oriented Programming (OOP) – construction of software systems using object oriented concepts as inheritance, polymorphism, encapsulation, dynamic binding. • Distinguish between OOD and OOP – OOD is relatively independent of the programming language used. – OOP is primarily concerned with programming language and software implementation issues OO Basics 5
  • 6. Object-Oriented Approach • Model objects that are part of the problem • Have objects exhibit their normal behavior • Add objects that do not have problem-space analogs • Have the objects work together to create a solution Design patterns help you identify less-obvious abstractions and the objects that can capture them. - GOF OO Basics 6
  • 7. Five Basic Characteristics of OO "Pure" object-orientation by Alan Kay (Smalltalk): • Everything is an object. • A program is a bunch of objects telling each other what to do by sending messages. • Each object has its own memory made up of other objects. • Every object has a type. • All objects of a particular type can receive the same message. OO Basics 7
  • 8. 4/9/2024 8 Basic Principles of Object Orientation Object Orientation Encapsulation Abstraction Hierarchy Polymorphism
  • 9. What Is Abstraction? • The essential characteristics of an entity that distinguishes it from all other kinds of entities. • Defines a boundary relative to the perspective of the viewer. • Is not a concrete manifestation, denotes the ideal essence of something. 4/9/2024 9 Salesperson: Not saying Which salesperson – just a salesperson in general!!! Customer Product Manages Complexity
  • 10. What Is Encapsulation? • Hides implementation from clients. – Clients depend on interface. 4/9/2024 10 Improves Resiliency
  • 11. Encapsulation • "Encapsulation is a mechanism used to hide the data, internal structure, and implementation details of an object. All interaction with the object is through a public interface of operations." (Craig Larman) • A boundary exists around each object; – the boundary encapsulates the object’s characteristics (data elements) and behaviors (functionality). • The reason for hiding features is to: (1) keep users from touching parts of the object they shouldn’t touch; (2) allows creator of the object to change the object’s internal working without affecting the users of the object. 4/9/2024 11
  • 12. What Is Polymorphism? • The ability to hide many different implementations behind a single interface. 4/9/2024 12 Manufacturer A Manufacturer B Manufacturer C OO Principle: Encapsulation Remote Control
  • 13. Polymorphism • Occurs with inheritance. • Different subclasses may have different implementations of the identical operations • Allows you to treat an object as the base class, rather than as a specific inherited type. • Programmer doesn’t have to keep track of the specific subclasses, the system selects the correct operation based on the object type. • Accomplished at run time using dynamic binding. – lets you substitute objects that have identical interfaces for each other at run-time. 4/9/2024 13
  • 14. What is Hierarchy? 4/9/2024 14 Decreasing abstraction Increasing abstraction Asset RealEstate Savings BankAccount Checking Stock Security Bond Elements at the same level of the hierarchy should be at the same level of abstraction Levels of abstraction
  • 15. Basic Concepts of Object Orientation • Object • Class • Attribute • Operation • Interface • Package • Relationships 4/9/2024 15
  • 16. What is an Object? • Informally, an object represents an entity, either physical, conceptual, or software – Physical entity – Conceptual entity – Software entity 4/9/2024 16 Truck Chemical Process Linked List
  • 17. A More Formal Definition • An object is a concept, abstraction, or thing with sharp boundaries and meaning for an application • An object is something that has: – State – Behavior – Identity 4/9/2024 17
  • 18. What is a Class? • A class is a description of a group of objects with common properties (attributes), behavior (operations), relationships, and semantics – An object is an instance of a class • A class is an abstraction in that it: – Emphasizes relevant characteristics – Suppresses other characteristics 4/9/2024 18 OO Principle: Abstraction
  • 19. 4/9/2024 19 Sample Class a + b = 10 Class Course Properties Name Location Days offered Credit hours Start time End time Behavior Add a student Delete a student Get course roster Determine if it is full
  • 20. Representing Classes in the UML • A class is represented using a rectangle with three compartments: – The class name – The structure (attributes) – The behavior (operations) 4/9/2024 20 Professor - name - employeeID : UniqueId - hireDate - status - discipline - maxLoad + submitFinalGrade() + acceptCourseOffering() + setMaxLoad() + takeSabbatical() + teachClass()
  • 21. Classes of Objects • How many classes do you see? 4/9/2024 21
  • 22. Classes and Objects Relationship • A class is an abstract definition of an object – It defines the structure and behavior of each object in the class – It serves as a template for creating objects • Objects are grouped into classes 4/9/2024 22 Objects Class Professor Smith Professor Jones Professor Mellon Professor
  • 23. What Is an Attribute? • An attribute is a named property of a class that describes the range of values that instances of the property may hold. – A class may have any number of attributes or no attributes at all. 4/9/2024 23 Attributes Student - name - address - studentID - dateOfBirth
  • 24. What Is an Operation? • A service that can be requested from an object to effect behavior. An operation has a signature, which may restrict the actual parameters that are possible. • A class may have any number of operations or none at all. 4/9/2024 24 Operations Student + get tuition() + add schedule() + get schedule() + delete schedule() + has prerequisites()
  • 25. What is an Interface? • Interfaces formalize polymorphism • Interfaces support “plug-and-play” architectures 4/9/2024 25 Tube Pyramid Cube Shape Draw Move Scale Rotate <<interface>> Realization relationship (stay tuned for realization relationships)
  • 26. Interface • How do you get an object to do useful work for you? • Objects are known only through their interfaces • Every object presents an interface to the world. • Interface determines what you can get an object to do. • Represent a "contract" with other objects. • Communicate with objects by sending messages to them; an object’s interface is the set of messages an object will respond to. 4/9/2024 26
  • 27. What is a Package? • A package is a general purpose mechanism for organizing elements into groups • A model element which can contain other model elements • Uses – Organize the model under development – A unit of configuration managemen 4/9/2024 27 Package Name
  • 28. Relationships • Association – Aggregation • Dependency • Inheritance • Realization 4/9/2024 28 ConsoleWindow Window open() close() move() display() handleEvent() Event DialogBox Control association generalization
  • 29. Relationships: Association • Models a semantic connection among classes 4/9/2024 29 Professor University Works for Class Association Association Name
  • 30. Relationships: Association Aggregation • To model a “whole/part” relationship, use aggregation. • Aggregation represents a “has-a” or “is a part-of” relationship, meaning that an object of the whole has objects of the part. [Martin Fowler] 30 4/9/2024 Company Department * 1
  • 31. Association: Multiplicity and Navigation • Multiplicity defines how many objects participate in a relationships – Specified for each end of the association • Associations are bi-directional by default, but it is often desirable to restrict navigation to one direction 4/9/2024 31 Customer Account 1 0..* Multiplicity Navigation
  • 32. Relationships: Dependency • A relationship between two model elements where a change in one may cause a change in the other – E.g. Class A depends on class B: method of A manipulates objects of B in the parameters, local variables, or return types 4/9/2024 32 Package ClientPackage SupplierPackage Client Supplier Class Dependency relationship
  • 36. What Gets Inherited? • A subclass inherits its parent’s attributes, operations, and relationships • A subclass may: – Add additional attributes, operations, relationships – Redefine inherited operations (use caution!) • Common attributes, operations, and/or relationships are shown at the highest applicable level in the hierarchy 4/9/2024 36 Inheritance leverages the similarities among classes
  • 37. 4/9/2024 37 Example: What Gets Inherited Truck tonnage GroundVehicle weight licenseNumber Car owner register( ) getTax( ) Person 0..* Trailer 1 Superclass (parent) Subclass generalization size