Lecture - 6
Lecture - 6
Circle Triangle
radius Line angle
length
draw draw
computeArea draw computeArea
getLength
Example – Class Compatibility
File
size
…
open
print
…
draw Shape
View
draw
draw Shape
View
draw
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
nn nn nn
Line nn Circle Triangle Group
nn
nn nn
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
Menu View Shape
name noOfObjects color
isOpen selected n vertices
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
Search “is a kind of” by looking at keywords
like “such as”, “for example”, etc
n n
Line n Triangle Group
n
length angle noOfObjects
Circle
n
draw() radius draw() draw()
n
n draw()