Step-wise procedure to translate a problem statement into class diagram
"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."
Extract nouns in the 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.
Eliminate irrelevant classes.
- Editor - Very broad scope
- User – Out of system boundary
- commands – Broad scope
Add more classes by analyzing requirements
- Group - required to behave as a shape
- Individual shapes can be grouped together and can behave as a single shape
- View – editor must have a display area
Following classes have been identified:
- Shape
- Line
- Circle
- Triangle
- Menu
- Group
- View
Extract verbs connecting objects.
"Individual shapes can be grouped together"
- Group consists of lines, circles, triangles
- Group can also consists of other groups
(Composition)
Verify access paths.
View contains shapes
- View contains lines
- View contains circles
- View contains triangles
- View contains groups
(Aggregation)
Menu sends message to View
(Simple One-Way Association)
Extract properties of the object from the domain knowledge.
- Shape
- Color
- Vertices
- Line
- Color
- Vertices
- Length
- Circle
- Color
- Vertices
- Radius
- Triangle
- Color
- Vertices
- Angle
- Menu
- Name
- isOpen
- Group
- noOfObjects
- View
- noOfObjects
- selected
Extract verbs connected with an object.
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.
Eliminate irrelevant operations.
- Develop - out of system boundary
- Provides - have broad semantics
- Behave – broad semantics
Following are selected operations:
- Shape
- Draw
- Select
- Move
- Rotate
- Line
- Draw
- Select
- Move
- Rotate
- Circle
- Draw
- Select
- Move
- Rotate
- Triangle
- Draw
- Select
- Move
- Rotate
- Menu
- Open
- Select
- Move
- Rotate
- Group
- Draw
- Select
- Move
- Rotate
Extract operations using domain knowledge
- View
- Add
- Remove
- Group
- Show
Search “is a kind of” by looking at keywords like “such as”, “for example”, etc
"…shapes such as line, circle and triangle…"
- Line, Circle and Triangle inherits from Shape
By analyzing requiremens
"Individual shapes can be grouped together and can behave as a single shape"
- Group inherits from Shape