Professional Documents
Culture Documents
OOAD10 CaseStudy
OOAD10 CaseStudy
OOAD
322
Case study
□ Problem
■ A very simple problem to show the use of UML in analysis and design
■ It is taken from the “Applying UML and Patterns” book of Claig Larman
■ A dice game
□ They player rolls 10 times 2 dice. If the total of two dice is 7, he
gains 10 points. At the end of the game, the score is saved to the
scoreboard
OOAD
323
Main Activities of Software Development
Requirements
Analysis Design
Gathering
Design the solution /
Define requirement Define the conceptual model
software plan
specification
Maintenance
Post-install review
Support docs
Active support
OOAD
324
Case study
□ Requirement analysis
■ Use-case diagram
Play
■ Use-case: Play
□ Description: The player rolls 2 dice 10 times. If each time the total
is 7, he receives 10 points.
OOAD
325
Case study
□ Requirement analysis
■ Activity diagram
□ Some activities are linked to the graphical user interface
[view]
[play] [exit]
Roll dice
[true]
OOAD
326
Use-case
□ Requirement analysis
■ Activity diagram
□ The relationship between the use-case diagram and activity diagram
Menu
[view]
[play] [exit]
Roll dice
View High Score
Player Turn < 10
[true]
[false]
OOAD
327
Main Activities of Software Development
Requirements
Analysis Design
Gathering
Design the solution /
Define requirement Define the conceptual model
software plan
specification
Maintenance
Post-install review
Support docs
Active support
OOAD
328
Case study
□ Analysis
OOAD
329
Case study
rolls
Player Die
1 2
1 2
plays
includes
DiceGame
1
1
1
scoring
1
HighScore
OOAD
330
Case study
s() d1:Die
ll
ro
2:
1: play()
3: r
:DiceGame :Player olls
()
d2:Die
OOAD
331
Case study
rolls
Player
Die
-name
1 2 -faceValue : int = 1
-score : int = 0
+rolls()
+play()
2
1
plays
includes
DiceGame
1
1
1
scoring
1
HighScore
OOAD
332
Case study
rolls
Player
Die
-name
1 2 -faceValue : int = 1
-score : int = 0
+rolls()
+play()
2
1
plays
includes
DiceGame
1
1
) d1:Die
ro lls( 1
2: scoring
1: play() 1
3: r
:DiceGame :Player olls HighScor
()
d2:Die
OOAD
333
Case study
□ Sequence diagram
1: play()
2: rolls()
3: rolls()
OOAD
334
Case study
2: Die()
3: Die()
4: start()
Player(name)
OOAD
335
Case study
cancel
start game
start
Ready to Play Player ready
exit
cancel play
OOAD
336
Case study
Menu
cancel
cancel play
Roll dice
[turn >= 10]
Turn < 10 In progress
[true]
OOAD
337
Case study
OOAD
338
Case study
□ The treatment of the scoreboard must be taken into account: the update
and the creation
Menu
[view]
[play] [exit]
Roll dice
View High Score
Player Turn < 10
[true]
[false]
No treatment
OOAD
339
Case study
2: Die()
3: Die()
4: HighScore()
5: start()
6: Player(name)
OOAD
340
Case study
1: Player()
2: play() 3: rolls()
4: rolls()
5: Entry(name, score)
6: add(:Entry)
OOAD
341
Case study
□ Class diagram
Player rolls
Die
-name
1 -faceValue : int = 1
-score : int = 0 2
+rolls()
+play()
+Die()
+Player()()
2
1
plays
DiceGame includes
1
+DiceGame() 1
+start()
1 scoring
1
OOAD
342
Main Activities of Software Development
Requirements
Analysis Design
Gathering
Design the solution /
Define requirement Define the conceptual model
software plan
specification
Maintenance
Post-install review
Support docs
Active support
OOAD
343
Case study
□ Design
OOAD
344
Case study
□ General architecture
■ Classical three layer architecture
Presentation
Persistence
OOAD
345
Case study
UI
UI : presentation layer
Core : Business logic layer Core Util
DB : Persistence layer
Util : utility services/classes/functionalities
DB
OOAD
346
Case study
Player rolls
Die
-name
1 -faceValue : int = 1
-score : int = 0 2
La classe DiceGame ne possède +play()
+rolls()
+Die()
+Player()
qu’un seul objet
La classe HighScore ne possède 1
2
OOAD
347
Case study
Singleton
static uniqueSingleton
other attributs …
return uniqueSingleton;
static instance()
other operations …
OOAD
348
Case study
HighScore
contains Entry
-$hs : HighScore = null
-name
+HighScore() 1 * -score
public static HighScore getInstance{ +getInstance() : HighScore
return HighScore; +add() +Entry(name, score)()
} +load()
+save()
OOAD
349
Case study
Subject Observer
observer
attach(o Observer) update()
dettach(o Observer)
for all o in observer
notify() o.update()
ConcreteSubject ConcreteObserver
subject
getState() update()
setState() observerState
subjectState return subjectState;
observerState=
subject.getState()
OOAD
350
Case study
Observable
-changed : bool = false «interface»
Observer
+notifyObserrvers()
+addObserver() +update(o : Observable, arg : Object)()
+...()
Player Die
-name -faceValue : int = 1
-score : int = 0 +rolls()
+play() +Die()
+Player() +display() DieView
+display()
+DieView(die : Die)()
PlayerView +update(o : Observable, arg : Object)()
OOAD
351
Case study
Observable
-changed : bool = false «interface»
Observer
+notifyObserrvers ()
+ update (o : Observable , arg : Object )()
+addObserver ()
+...()
JPanel
Player Die
-name -faceValue : int = 1
-score : int = 0 +rolls ()
+play () +Die ()
+Player () +display () DieView
+display ()
OOAD
352
Case study
□ Sequence diagram describes the interactions between Die object the its
view
1:getValue()
2:setValue()
3:notifyObservers()
4:update(Observable, Object)
OOAD
353
Case study
OOAD
354
Case study
1:roll()
Singleton
2:getInstance()
Randomizer
+getInstance() 3:Randomizer()
+getValue()
4:Random()
5:getValue()
Random
6:nextInt()
OOAD
355
Case study
…
Creator product = factoryMethod();
* 1 factoryMethod() …
Product anOperation()
<<create>>
OOAD
356
Case study
HighScore DBKit
- $ hs : HighScore = null - :
+ HighScore () + makeKit ()
+ getInstance () : HighScore
+ add ()
+ load ()
+ save ()
FileKit JDBCKit
HighScoreFile
HighScoreJDBC
+ makeKit () + makeKit ()
+ HighScoreFile ()
+ HighScoreJDBC ()
+ load ()
+ load ()
+ save ()
+ save ()
OOAD
357
Case study
1:JDBCKit()
2:getInstance()
DiceGame sees JDBCKit as DBKit
and HighScoreJDBC as HighScore
3:DiceGame()
4:makeKit()
Only RealPlayer knows that
5:HighScoreJDBC() he uses JDBCKit, while
DiceGame does not!
6:load()
7:exit() 8:getInstance()
9:save()
OOAD
358
Case study
□ Deployment diagram
JDBC Connection
JDBC Computer
Game Computer
OOAD
359
Main Activities of Software Development
Requirements
Analysis Design
Gathering
Design the solution /
Define requirement Define the conceptual model
software plan
specification
Maintenance
Post-install review
Support docs
Active support
OOAD
360
Case study
OOAD
361