Object-Oriented Programming (OOP)
Object-Oriented Programming (OOP)
Object-Oriented Programming (OOP)
(OOP)
Object-Oriented Modeling
An Example
Problem Statement
• Develop a graphic editor that can draw
different geometric shapes such as line, circle
and triangle. User can select, move or rotate a
shape. To do so, editor provides user with a
menu listing different commands. Individual
shapes can be grouped together and can
behave as a single shape.
Identify Classes
Extract nouns in the problem statement
• Shape • Group
• Line • View
• Circle
• Triangle
• Menu
Object Model – Graphic Editor
Shape Group
Line Menu
Circle
View
Triangle
Identify Associations
Extract verbs connecting objects
n n n
Line n Circle Triangle Group
n
n n
Identify Attributes
Extract properties of the object
– From the problem statement
• Line • Triangle
– Color – Color
– Vertices – Vertices
– Length – Angle
• Circle • Shape
– Color – Color
– Vertices – Vertices
– Radius
…Identify Attributes
Extract properties of the object
– From the domain knowledge
• Group • Menu
– noOfObjects – Name
• View – isOpen
– noOfObjects
– selected
Object Model – Graphic Editor
n n n
Line n Circle Triangle Group
length radius angle noOfObjects
n
n
n
Identify Operations
Extract verbs connected with an object
• Line • Circle
– Draw – Draw
– Select – Select
– Move – Move
– Rotate – Rotate
…Identify Operations
Following are selected operations:
• Triangle • Shape
– Draw – Draw
– Select – Select
– Move – Move
– Rotate – Rotate
…Identify Operations
Following are selected operations:
• Group • Menu
– Draw – Open
– Select – Select
– Move – Move
– Rotate – Rotate
…Identify Operations
Extract operations using domain knowledge
• View
– Add – Select
– Remove – Move
– Group – Rotate
– Show
View
Menu noOfObjects Shape
selected
name color
isOpen vertices
add()
remove()
open() n draw()
group()
select() select()
show()
move() move()
select()
rotate() rotate()
move()
rotate() n
n n
Line n Triangle Group
n
length angle noOfObjects
Circle
n
draw() radius draw() draw()
n
n draw()
Identify Inheritance
Share associations
Share attributes
Share operations
n n
Line n Triangle Group
n
length angle noOfObjects
Circle
n
draw() radius draw() draw()
n
n draw()