2009 04 Phantichuse-case

Embed Size (px)

Text of 2009 04 Phantichuse-case

Gio trnh Phn tch v thit k hng i tng bng UML

Phn tch Use-Case

Phn tch Use-Case Dng Anh c

1

Mc tiu Tm hiu mc ch ca cng on Use-Case Analysis v tr ca n trong chu k sng ca qui trnh pht trin phn mm Xc nh cc class thc hin mt use- case flow of events Phn phi cc hnh vi (behaviour) ca use-case v cc class ca n, thng qua vic xc nh nhim v ca cc class Pht trin cc use-case realization m hnh ha collaboration gia cc th hin ca cc class xc nh

Phn tch Use-Case Dng Anh c

2

Use-Case Analysis trong ng cnh

Architectural AnalysisReview the Architecture Architecture Reviewer

Architect

Architectural Design

Describe Concurrency

Describe Distribution

Use-Case Analysis Designer Use-Case Design

Subsystem Design Review the Design

Design Reviewer

Class Design

Phn tch Use-Case Dng Anh c

3

Tng quan Use-Case Analysis

Software Architecture Glossary Use-Case Document Modeling Guidelines Supplementary Specifications

Analysis Classes

Use-Case Realization (identified)

Use-Case Analysis

Use-Case Realization (developed)

Use-Case ModelPhn tch Use-Case Dng Anh c

Analysis Model (optional)4

Design Model

Cc bc trong Use-Case Analysis B sung m t Use-Case Vi mi use-case realization Tm cc Class t Use-Case Behavior Phn b Use-Case Behavior v cc Class Vi mi analysis class tm thy M t nhim v ca chng M t cc Attribute v cc Association Lng gi (qualify) cc Analysis Mechanism Hp nht cc Analysis Class CheckpointsPhn tch Use-Case Dng Anh c

5

Cc bc trong Use-Case Analysis B sung m t Use-Case Vi mi use-case realization Tm cc Class t Use-Case Behavior Phn b Use-Case Behavior v cc Class Vi mi analysis class tm thy M t nhim v ca chng M t cc Attribute v cc Association Lng gi (qualify) cc Analysis Mechanism Hp nht cc Analysis Class CheckpointsPhn tch Use-Case Dng Anh c

6

Supplement the Use-Case Description

H thng hin th mt danh sch cc lp hc (course offerings).Phn tch Use-Case Dng Anh c

H thng truy vn v hin th mt danh sch cc lp hc ang m t CSDL course catalog k tha t h thng c.

7

Cc bc trong Use-Case Analysis B sung m t Use-Case Vi mi use-case realization Tm cc Class t Use-Case Behavior Phn b Use-Case Behavior v cc Class Vi mi analysis class tm thy M t nhim v ca chng M t cc Attribute v cc Association Lng gi (qualify) cc Analysis Mechanism Hp nht cc Analysis Class CheckpointsPhn tch Use-Case Dng Anh c

8

Review: Class L mt s tru tng ha M t mt nhm cc i tng c chung: Properties (attributes) Behavior (operations) Relationships Ng ngha (Semantics)Class Name Professor name empID create( ) save( ) delete( ) change( )

AttributesOperations

Phn tch Use-Case Dng Anh c

9

Review: Use-Case RealizationUse-Case Model Design Model

Use Case

Use-Case Realization

Sequence Diagrams

Collaboration Diagrams

Use Case Class Diagrams10

Phn tch Use-Case Dng Anh c

Tm cc Class t Use-Case Behavior Ton b hnh vi ca mt use case phi c phn b v cho cc analysis class

Phn tch Use-Case Dng Anh c

11

Th no l mt Analysis Class?

Use-case behavior coordination

System boundary

System information

Phn tch Use-Case Dng Anh c

12

Analysis Classes: A First Step Towards Executables

Use Cases

Analysis Design Classes ElementsUse-Case Analysis

Source Code

Exec

Phn tch Use-Case Dng Anh c

13

Th no l mt Boundary Class? Lm trung gian giao tip vi nhng g nm ngoi h thng Mt s kiu Cc User interface class Cc System interface class Cc Device interface class Mt boundary class cho 1 cp actor/use caseAnalysis class stereotype

Ph thuc mi trngPhn tch Use-Case Dng Anh c

14

Vai tr ca Boundary Class

Customer

M hnh ha s tng tc gia system v mi trng ca nPhn tch Use-Case Dng Anh c

15

V d: Tm cc Boundary Class Mt boundary class cho 1 cp actor/use case

Student

Register for Courses

Course Catalog System

RegisterForCoursesForm

CourseCatalogSystem

Phn tch Use-Case Dng Anh c

16

Guidelines: Boundary Class Cc User Interface Class Tp trung vo nhng thng tin g c th hin cho ngi dng KHNG tp trung vo cc chi tit UI Cc System v Device Interface Class Tp trung vo nhng protocols no phi nh ngha KHNG tp trung vo cch m cc protocol s c ci t Tp trung vo cc nhim v, ch khng phi chi tit!

Phn tch Use-Case Dng Anh c

17

Th no l mt Entity Class? Cc tru tng ha then cht ca systemAnalysis class stereotypeGlossary

Use Case

Business-Domain Model Architectural Analysis AbstractionsPhn tch Use-Case Dng Anh c

c lp mi trng18

Vai tr ca Entity Class

Customer

Lu tr v qun tr cc thng tin trong systemPhn tch Use-Case Dng Anh c

19

V d: Tm cc Entity Class Dng use-case flow of events nh input Cc tru tng ha then cht ca use case Hng tip cn truyn thng (nouns filtering) Gch di cc cm danh t trong flow of events Loi b cc ng vin d tha Loi b cc ng vin m h, khng r rng Loi b cc actor (ngoi phm vi) Loi b cc kin trc ci t Loi b cc attribute ( li dng sau) Loi b cc operation

Phn tch Use-Case Dng Anh c

20

V d: Candidate Entity Class Register for Courses (Create Schedule)

Student CourseOffering

Schedule

Phn tch Use-Case Dng Anh c

21

Review: Generalization Mt class chia s cu trc v/hoc hnh vi ca mt hay nhiu class Superclass Mi quan h L mt dng (parent) ca Trong phn tch, s dng mc n gin, s siAccount balance name number Withdraw() CreateStatement()

Generalization Relationship

Checking

Savings GetInterest() Withdraw()

SubclassesWithdraw()

Phn tch Use-Case Dng Anh c

22

Finding Generalization: Generalization of ClassesStock Savings Checking

Tng qut hn

RealEstate

Bond

Asset

BankAccount

Security

RealEstate

Savings

Checking

Stock

Bond

Phn tch Use-Case Dng Anh c

23

Finding Generalization: Specialization of Classes

Asset

Asset

BankAccount

Security

RealEstate

Savings

Checking

Stock

Bond

Chuyn bit hn

Phn tch Use-Case Dng Anh c

24

Example: Generalization (Chia s ng ngha)Part-timeStudent Full-timeStudentname address studentID gradDate

Khng c s tng qut ha

name address studentID numberCourses

Student

C s tng qut ha

name address studentID

FulltimeStudent gradDate

ParttimeStudent

maxNumCourses

Phn tch Use-Case Dng Anh c

25

Th no l mt Control Class? Nh iu phi cc hnh vi ca Use-case Ch mt control class cho mt use case

Use Case

Analysis class stereotype

Ph thuc use-case, c lp mi trng

Phn tch Use-Case Dng Anh c

26

Vai tr ca Control Class

Customer

iu phi cc hnh vi ca use-casePhn tch Use-Case Dng Anh c

27

V d: Tm cc Control Class Mt control class cho mt use case

Student

Register for Courses

Course Catalog System

RegistrationController

Phn tch Use-Case Dng Anh c

28

Example: Summary: Analysis Classes

Student

Register for Courses

Course Catalog System

Use-Case Model Design Model RegisterForCoursesForm RegistrationController CourseCatalogSystem

Student

Schedule

CourseOffering

Phn tch Use-Case Dng Anh c

29

Cc bc trong Use-Case Analysis B sung m t Use-case Vi mI use-case realization Tm cc Class t Use-Case Behavior Phn b Use-Case Behavior v cc Class Vi mi analysis class tm thy M t nhim v ca chng M t cc Attribute v cc Association Lng gi (qualify) cc Analysis Mechanism Hp nht cc Analysis Class CheckpointsPhn tch Use-Case Dng Anh c

30

Phn b Use-case v cc Class i vi mi use-case flow of events: Xc nh cc analysis class Gn kt cc trch nhim ca use-case cho cc analysis class M hnh ha tng tc ca cc analysis class trong interaction diagram

Sequence Diagrams Use Case

Collaboration Diagrams

Use-Case Realization

Phn tch Use-Case Dng Anh c

31

Interaction Diagrams Generic term that applies to several diagrams that emphasize object interactions Sequence Diagram Time oriented view of object interaction

Sequence Diagrams

Communication Diagram (or Collaboration Diagram) Structural view of messaging objectsCommunication DiagramsPhn tch Use-Case Dng Anh c

32

Guidelines: Allocating Responsibilities to Classes Dng cc A.Class stereotype lm guide: Cc Boundary Class Cc hnh vi lin quan n s giao tip vi actor Cc Entity Class Cc hnh vi lin quan n d liu c gi trong mt abstraction Cc Control Class Cc hnh vi c th cho mt use case hoc mt phn rt quan trng ca flow of events

(cn tip)Phn tch Use-Case Dng Anh c

33

Guidelines: Allocating Responsibilities to Classes (tt) Ai c d liu cn cho vic thc hin nhim v? Mt class c d liu, hy nhim v cng vi d liu Nhiu class c d liu : Hy nhim v trong 1 class v thm quan h vi cc class khc. To mt class mi, nhim v trong class mi ny, v thm quan h vi cc class c Hy nhim v trong control class, v thm quan h vi cc class cn thc hin nhim v

Phn tch Use-Case Dng Anh c

34

The Anatomy of Sequence DiagramsClient Object

Supplier Object

:Client

:Supplier

Object Lifeline1: PerformResponsibility y l mt script mu

Reflexive Message

Message