Thursday, January 12, 2012

Step 4 - The UML Code Design

Before going any further, I thought I'd perform a simple object analysis to discover the objects, methods and properties in the application.

A Quick & Dirty Object Analysis

I forget where I learned this, but this object decomposition technique has been a really helpful. First, I write a paragraph that describes what happens in the application in just plain English. Next I read over the paragraph and bold the nouns and underline the verbs. The nouns become the classes and the verbs are the methods (and a lot of adjectives in the paragraph will end up as properties).

So, for this application, the description would be pretty straight-forward:
The player selects a game from one of several categories. The board is displayed with a Next and Previous button underneath it. The player clicks next and a stone is displayed on the board with a label (e.g. a number or shape) and may be highlighted. The player can click previous and the last stone will be removed from the board. After the stones are displayed the SGF game file will be interpreted. Comments are displayed if there are any in the SGF game file for that move. The player can either dismiss a comment or click Next to see the next comment.
So separating out the nouns (classes) and verbs (methods) this quick & dirty object analysis provides the following:

Nouns
player
game ( SGF game file )
category
stone
comment
board

Verbs
select {game}
draw {stone}
remove {stone}
select {stone}
interpret {comment}
display {comment}
dismiss {comment}
click_next {player? game? I'm not too sure right now what this should apply to...}
click_previous {player? game? I'm not too sure right now what this should apply to...}

UML Diagram
So taking these, it's easy to build a rough UML diagram:


No comments:

Post a Comment