0% found this document useful (0 votes)
104 views44 pages

SAD - Ch10 - Case Study

This document summarizes a case study on analyzing and designing a dice game using UML. It describes the requirements of rolling dice and tracking scores. The analysis models the problem domain using use case diagrams, activity diagrams, class diagrams, and collaboration diagrams. The design refines the models, applies design patterns like singleton and observer, and defines the architecture with packages for presentation, business logic, and persistence layers. The case study demonstrates applying UML diagrams throughout the software development process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
104 views44 pages

SAD - Ch10 - Case Study

This document summarizes a case study on analyzing and designing a dice game using UML. It describes the requirements of rolling dice and tracking scores. The analysis models the problem domain using use case diagrams, activity diagrams, class diagrams, and collaboration diagrams. The design refines the models, applies design patterns like singleton and observer, and defines the architecture with packages for presentation, business logic, and persistence layers. The case study demonstrates applying UML diagrams throughout the software development process.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 44

SYSTEMS

ANALYSIS AND DESIGN


Le Viet Truong
Faculty of Computer Science
Vietnam - Korea University of Information and Communication Technology (VKU)
Case study
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
• The 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

3
Main Activities of Software Development
Requirements Gathering Analysis Design

Define requirement Define the conceptual Design the solution /


specification model software plan

Implementation Integration and Test


Deployment
Code the system based on Prove that the system meets
Installation and training
the design the requirements

Maintenance

Post-install review
Support docs
Active support

4
Case study

• Requirement analysis
• Use-case diagram

• Use-case: Play
• Description: The player rolls 2 dice 10 times. If each time the total is 7, he receives 10 points.

• Use-case: View High Score


• Description: They player consults the scores

5
Case study

• Requirement analysis
• Activity diagram
• Some activities are linked to the graphical user interface

[view ] [play ] [exit ]

View High Score Play

Roll dice

[true ]

Turn < 10 [false ]

Update High Score

6
Use-case

• Requirement analysis
• Activity diagram
• The relationship between the use-case diagram and activity diagram

7
Main Activities of Software Development
Requirements Gathering Analysis Design

Define requirement Define the conceptual Design the solution /


specification model software plan

Implementation Integration and Test


Deployment
Code the system based on Prove that the system meets
Installation and training
the design the requirements

Maintenance

Post-install review
Support docs
Active support

8
Case study

• Analysis
• Modelling the real world
• Independent of the implementation
• Modelling of the domain: conceptual class diagram
• Modelling of the dynamic behaviour of the system: collaboration diagram

9
Case study

• Modeling of conceptual class diagram

10
Case study

• A first collaboration diagram

11
Case study

• A first class diagram

12
Case study

• Collaboration diagram and class diagram

13
Case study

• Sequence diagram

14
Case study

• The creation of objects at the beginning of the game (DiceGame) for a player

15
Case study

• State diagram: modelling the states of the DiceGame

16
Case study

• Detection of inconsistency between the activity diagram and the state diagram

17
Case study

• Modification of the activity diagram as well as the envisaged graphical user interface

18
Case study

• The treatment of the scoreboard must be taken into account: the update and the creation

No treatment

19
Case study

• Sequence diagram: manage high score, create new player

20
Case study

• Sequence diagram: add high score to score board

21
Case study

• Class diagram

22
Main Activities of Software Development
Requirements Gathering Analysis Design

Define requirement Define the conceptual Design the solution /


specification model software plan

Implementation Integration and Test


Deployment
Code the system based on Prove that the system meets
Installation and training
the design the requirements

Maintenance

Post-install review
Support docs
Active support

23
Case study

• Design
• Take into account the implementation
• Manage the graphical user interface part
• Manage the persistence of scoreboard
• Define the logical architecture
• Define the physical architecture
• Introduce the technical class permitting to implement the architecture

24
Case study

• General architecture
• Classical three layer architecture

Presentation

Business Logic

Persistence

25
Case study

• A package diagram corresponds to the architecture

UI : presentation layer
Core : Business logic layer
DB : Persistence layer
Util : utility services/classes/functionalities

26
Case study

• Use design patterns to improve the classes of “Core” package

Class DiceGame has only one object


Class HighScore has only one object

Design pattern : Singleton

27
Case study

• Singleton design pattern


Singleton
static uniqueSingleton
other attributs … return uniqueSingleton;

static instance()
other operations …

• Application to DiceGame and HighScore.

28
Case study

• Modified class diagram

29
Case study

• Observer design pattern

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
return subjectState;
subjectState

observerState=
subject.getState()

30
Case study

• Application of Observer design pattern to improve the class diagram


• Decouple the graphical views and objects for the dice and players
• Application of Observer pattern
• Die and Player classes are ConcreteSubject class
• Introduce DieView et PlayerView as ConcreteObserver classes

31
Case study

• User view are instances of javax.swing.JPanel.java


Observable
- changed : bool = false «interface»
Observer
+ notifyObserrvers ()
+ addObserver () + update (o : Observable , arg : Object )()
+...()

JPanel
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 )()

+ PlayerView ( player : Player )()


+ update (o : Observable , arg : Object )()

32
Case study

• Sequence diagram describes the interactions between Die object the its view

33
Case study

• The design of “UI” package

34
Case study

• The design of “Util” package

35
Case study

• The design of “DB” package


• How to ensure the independence between “Core” and “DB” package
• In order to be able to use several persistence types
• File (serialisation)
• Relation Database Management System (via JDBC)

• Use FactoryMethod design pattern …


Creator product = factoryMethod();
* 1 factoryMethod() …
Product
anOperation()

ConcreteProduct CreateCreator return new ConcreteProduct();


factoryMethod()
<<create>>

36
Case study

• The design of “DB” package



HighScore DBKit
Class diagram - $ hs : HighScore = null - :

+ HighScore () + makeKit ()
+ getInstance () : HighScore
+ add ()
+ load ()
+ save ()

FileKit JDBCKit
HighScoreFile
HighScoreJDBC

+ makeKit () + makeKit ()
+ HighScoreFile ()
+ HighScoreJDBC ()
+ load ()
+ load ()
+ save ()
+ save ()

<< create >>

Note : HighScore class is a Singleton

37
Case study

• The design of the “DB” package


• Sequence diagram

38
Case study

• Deployment diagram

39
Main Activities of Software Development
Requirements Gathering Analysis Design

Define requirement Define the conceptual Design the solution /


specification model software plan

Implementation Integration and Test


Deployment
Code the system based on Prove that the system meets
Installation and training
the design the requirements

Maintenance

Post-install review
Support docs
Active support

40
Case study

• Complete the interaction diagrams


• Generate the code

41
Conclusions
Conclusions

• Distinction between functional approach and object-oriented approach


• Master the basic object-oriented concepts

• UML: a modelling language


• Need a development process
• Different views
• Different models
• Use of the models in different development activities

• Master the main diagrams


• Use-case diagram
• Class diagram
• Interaction diagram

43
Conclusions

• The UML concepts can be extended


• The extensions

• Transformation of models to code


• Models independent of programming language

• The automatic code generation is only a supplement


• The models guide the coding process

• Master design principles


• GRAPS principles/patterns
• Some design patterns

44

You might also like