tongquanvephantichvathietke

84
Phân tích Use-Case Dương Anh Đức 1 Phân tích Use-Case Phân tích thiết kế hướng đối tượng

Upload: hachibinh2010

Post on 04-Nov-2015

3 views

Category:

Documents


0 download

DESCRIPTION

Phân tích thiết kế Hướng Đối Tượng

TRANSCRIPT

Phân tích Use-Case
 
Mc tiêu
Tìm hiu mc ích ca công on Use!ase "na#$sis %& t'í ca n( t'ong chu k) sng ca *ui t'ình +h,t t'in +h-n m.m
/,c &nh c,c c#ass th0c hi1n m2t use case 3#o4 o3 e%ents
Phân +hi c,c h5nh %i 67eha%iou'8 ca usecase %. c,c c#ass ca n(9 thông *ua %i1c :,c &nh nhi1m % ca c,c c#ass
 
 Architect
Designer 
 
Supplementary Speciications
Use-Case Reali$ation %#evelope#&
Design "o#el
Các bc trong Use-Case Analysis
sung !" t Use-Case #i !$i use-case reali%ation
T&! các Class t' Use-Case eha(ior )h*n b Use-Case eha(ior (+ các Class
#i !$i analysis class , t&! th.y M" t nhi/! ( c0a ch1ng M" t các Attribute (2 các Association 34ng giá 5quali6y7 các Analysis Mechanis!
849 nh.t các Analysis Class Chec:9oints
 
Các bc trong Use-Case Analysis
sung !" t Use-Case #i !$i use-case reali%ation
T&! các Class t' Use-Case eha(ior )h*n b Use-Case eha(ior (+ các Class
#i !$i analysis class , t&! th.y M" t nhi/! ( c0a ch1ng M" t các Attribute (2 các Association 34ng giá 5quali6y7 các Analysis Mechanis!
849 nh.t các Analysis Class Chec:9oints
 
Phân tích Use-Case Dng Anh c )
* +, thng hi.n th/ m0t #anh sch cc lp hc %course oerings&
* +, thng truy v5n v6 hi.n th/ m0t #anh sch cc lp hc 7ang m8 t9 CSD: course catalog ;< th9a t9 h, thng c=
;u99le!ent the Use-Case <escri9tion
sung !" t Use-Case #i !$i use-case reali%ation
T&! các Class t' Use-Case eha(ior )h*n b Use-Case eha(ior (+ các Class
#i !$i analysis class , t&! th.y M" t nhi/! ( c0a ch1ng M" t các Attribute (2 các Association 34ng giá 5quali6y7 các Analysis Mechanis!
849 nh.t các Analysis Class Chec:9oints
Các bc trong Use-Case Analysis
 
Professor
=e(ie>? Class
:6 m0t s@ tr9u tBng ha " tE m0t nhm cc 7i tBng c chungF
Groperties %attributes& Hehavior %operations& Relationships IgJ nghKa %Semantics&
 
Class Diagrams
SeMuence Diagrams
Use Case
NNboun#aryOO
NNboun#aryOONNcontrolOO
T&! các Class t' Use-Case eha(ior 
 
NNcontrolOO
 
Use Cases Analysis Classes
 
Ph thuc môi trng 
Th@ n2o l2 !t ounary ClassB
:6m trung gian giao ti<p vi nhJng g nVm ngo6i h, thng "0t s ;i.u
Cc User interace class Cc System interace class Cc Device interace class
Mt boundary class cho 1 cp actoruse case
 
Phân tích Use-Case Dng Anh c 1'
Mô hình hóa s tng tác gia system và môi trng ca nó
Customer 
 
Course Catalog SystemRegister or CoursesStu#ent
NNboun#aryOO RegisterWorCoursesWorm
NNboun#aryOO CourseCatalogSystem
"0t boun#ary class cho 1 cXp actorYuse case
 
Phân tích Use-Case Dng Anh c 1)
T! trung và" các nhi#m v$ ch% &hông !h'i chi ti(t) 
Iuielines? ounary Class
Cc User Znterace Class P[p trung v6o nhJng thng tin g 7Bc th. hi,n cho ng\i
#]ng J8KLI t[p trung v6o cc chi ti<t UZ
 
!lossary
Th@ n2o l2 !t Dntity ClassB
 
,u tr và -u'n tr. các thông tin tr"ng system
Customer 
 
#H ? T&! các Dntity Class
D]ng use-case low o events nh input Cc tr9u tBng ha then cht cQa use case +ng ti<p c[n truyTn thng %nouns iltering&
 
Stu#ent
Courseering
Sche#ule
Register or Courses %Create Sche#ule&
 
Account
@u7c#asses
=e(ie>? Ienerali%ation
"0t class chia sj c5u trc v6YhoXc h6nh vi cQa m0t hay nhiTu class
"i Muan h, k:6 m0t #_ng cQa
 
Fining Ienerali%ation? Ienerali%ation o6 Classes
Savings Chec;ing Stoc;
Fining Ienerali%ation? ;9eciali%ation o6 Classes
 Asset
 Asset
 
Student
numberCourses
 Không có s tng quát hóa
Có s tng quát hóa
stu#entZD
 
Use Case
NNcontrolOO
Th@ n2o l2 !t Control ClassB
 
#ai trG c0a Control Class
*i1u !h2i các hành vi ca use/case
Customer 
Course Catalog SystemRegister or CoursesStu#ent
NNcontrolOO RegistrationController 
"0t control class cho m0t use case
 
Use-Case Moel
<esign Moel
NNboun#aryOO RegisterWorCoursesWorm
NNboun#aryOO CourseCatalogSystem
sung !" t Use-case #i !$N use-case reali%ation
T&! các Class t' Use-Case eha(ior )h*n b Use-Case eha(ior (+ các Class
#i !$i analysis class , t&! th.y M" t nhi/! ( c0a ch1ng M" t các Attribute (2 các Association 34ng giá 5quali6y7 các Analysis Mechanis!
849 nh.t các Analysis Class Chec:9oints
Các bc trong Use-Case Analysis
 
Use Case Use-Case =eali%ation
SeMuence Diagrams Collaboration Diagrams
)h*n b Use-case (+ các Class
 qi vi mi use-case low o eventsF c 7/nh cc analysis class !n ;<t cc trch nhi,m cQa use-case cho cc analysis
class " hnh ha tdng tc cQa cc analysis class trong
interaction #iagram
Interaction Diagrams
!eneric term that applies to several #iagrams that emphasi$e obect interactions
SeMuence Diagram Pime oriente# view o obect interaction
Communication Diagram %or Collaboration Diagram& Structural view o messaging obects
Communication Diagrams
SeMuence Diagrams
Iuielines? Allocating =es9onsibilities to Classes
D]ng cc AClass stereotype l6m gui#eF Cc Houn#ary Class
* Cc h6nh vi lin Muan 7<n s@ giao ti<p vi actor  Cc ntity Class
* Cc h6nh vi lin Muan 7<n #J li,u 7Bc gi trong m0t abstraction
Cc Control Class
* Cc h6nh vi 7Xc th] cho m0t use case hoXc m0t phn r5t Muan trng cQa low o events
)c*n ti+p,
Phân tích Use-Case Dng Anh c 34
Iuielines? Allocating =es9onsibilities to Classes 5tt7
 Ai c #J li,u cn cho vi,c th@c hi,n nhi,m v` "0t class c #J li,uf hxy 7. nhi,m v` c]ng vi #J li,u IhiTu class c #J li,u F
* +xy 7. nhi,m v` trong 1 class v6 thm Muan h, vi cc class ;hc
* P_o m0t class mif 7. nhi,m v` trong class mi n6yf v6 thm Muan h, vi cc class c=
 
1F GerormResponsibility
0efleive Message b.ect 2ifeline
11F GerormAnother  Responsibility
The Anato!y o6 ;equence <iagra!s
3ierarchical Message 4umbering 
Phân tích Use-Case Dng Anh c 3(
Register for Courses Use Case – Basic o!" Create a #che$u%e 
1 Phe Stu#ent selects zcreate sche#ulez 2 Phe system retrieves a list o available course oerings 
rom the Course Catalog System 3 Phe system #isplays a blan; sche#ule orm 4 Phe Stu#ent selects 4 primary course oerings an# 2
alternate course oerings rom the list o available oerings nce the selections are complete the Stu#ent selects zsubmitz
' +, thng t_o m0t l/ch hc cha nhJng hc phn sinh vin 7x 7{ng ;|
 
Ana%&sis C%asses
DEa!9le? ;equence <iagra!
 F Stu#ent
F CourseCatalogSystem
he available course oerings or this semester are #isplaye#
Stu#ent wishes to create a new sche#ule
1 YY create sche#ule% &
12 YY #isplay course oerings% &
11 YY get course oerings% &
111 YY get course oerings%orSemester&
13 YY #isplay blan; sche#ule% &
 At thisf point the Submit Sche#ule sublow is eecute#
2 YY select 4 primary an# 2 alternate oerings% &
21 YY create sche#ule with oerings% & 211 YY create with oerings% &
 A blan; sche#ule is #isplaye# or the stu#ents to select oerings
212 YY a## sche#ule%Sche#ule&
1111 YY get course oerings% &
 
DEa!9le? ;equence <iagra! 5contQ7
 F RegisterWorCoursesWorm  F RegistrationControll
 
primary course oerings
 An attempt is ma#e to register the stu#ent or all selecte# course oerings
1 YY submit sche#ule% &
11 YY submit sche#ule% &
112 YY submit% &
1123 YY still open% &
112' YY a## stu#ent%Sche#ule&
1122 YY has pre-reMuisites%Courseering&
1124 YY any conlicts% &
1121 YY is selecte#% &
112( YY mar; as enrolle# in% &
111 YY save%
 
&
} has pre-reMuisitesf course oering openf an# no sche#ule conlicts ~
} is selecte# ~
Phân tích Use-Case Dng Anh c 4L
Use caseF •ith#raw  ActorF Client GurposeF To allo> the client to >ithra> money Gre-con#itionsF User  alreay logge-in Gost-con#itionsF A!ount is eucte 6ro! userRs account "ain lowF
1& Client initiates this usecase by selecting €with#raw€ 2& System #isplays all the accounts relate# to the Car an#
prompts to select any one 3& Client selects one account 4& System prompts or the a!ount %ast cash or & '& Client enter amount
 Alternative lowsF 2& ‚ 3& System selects the only one available account
Client User Account Amount Money Card Cash
Identify Nouns
 
#euence Diagram – Use case *ith$ra!
 F Client  F •ith#rawUZ  F •ith#rawControl  F Car# F Account
1F YY select with#raw% &
2F YY get list accounts% &
3F YY get accounts% &
'F YY #isplay account% &
(F YY select account% &
)F YY enter money% &
>F YY with#raw% &
 
1F GerormResponsibility
3+ient 456ect 
7u!!+ier 456ect 
 
DEa!9le? Collaboration <iagra!
 F Stu#ent
 F CourseCatalogSystem
12 YY #isplay course oerings% & 13 YY #isplay blan; sche#ule% &
 F Course Catalog
1 YY create sche#ule% & 2 YY select 4 primary an# 2 alternate oerings% &
11 YY g
 
et course oerings% & 21 YY create sche#ule with oerings% &
211 YY create with oerings% &
111 YY get course oerings%orSemester&
212 YY a## sche#ule%Sche#ule&
1111 YY get course oerings% &
 
DEa!9le? Collaboration <iagra! 5contQ7
1124 YY any conlicts% &
 F RegisterWorCoursesWorm
11 YY
submit sche#ule% &
112 YY submit% & 111 YY save% & 1123 YY still open% &
112' YY a## stu#ent%Sche#ule&
1121 YY is selecte#% & 112( YY mar; as enrolle# in% &
1122 YY has pre-reMuisites%Courseering&
 
 Alternate Wlow 4 Alternate Wlow ' Alternate Wlow n
 Alternate Wlow 1 Alternate Wlow 2 Alternate Wlow 3
 AW1
 AW2
 AW3
 
Collaboration <iagra!s #s ;equence <iagra!s
Collaboration Diagrams Chƒ ra cc mi Muan h,
b sung cho cc tdng tc
Pr@c Muan ha tt hdn cc mu c0ng tc
Pr@c Muan ha tt hdn cc hi,u ng tc 70ng ln m0t 7i tBng c`
D„ s #`ng hdn trong cc v5n 7T cn giEi Muy<t t[p th.
SeMuence Diagrams Chƒ ra r r6ng chui cc
thng 7i,p Pr@c Muan ha tt hdn
to6n b0 lung s@ ;i,n Pt hdn cho cc 7Xc tE
real-time v6 cho cc scenario phc t_p
 
)c*n ti+p,
DEercise? Use-Case Analysis )art
+xy y #@ngF Use-Case "o#elf 7Xc bi,t l6 cc use-case lows o events Cc tr9u tBng haYclass then cht
+xy c 7/nh cc thng tin sau cho m0t use case c` th.F Cc analysis classf c]ng vi chng l6F
* Hrie #escriptions
* Stereotypes
 
DEercise? Use-Case Analysis )art 5tt7
…i m0t use case c` th.f hxy thi<t l[pF Use-case reali$ation interaction #iagram cho ti thi.u m0t
trong cc use-case lows o events
 
sung !" t Use-case #i !$N use-case reali%ation
T&! các Class t' Use-Case eha(ior )h*n b Use-Case eha(ior (+ các Classs
#i !$N analysis class , t&! th.y M" t nhi/! ( c0a ch1ng M" t các Attribute (2 các Association 34ng giá 5quali6y7 các Analysis Mechanis!
849 nh.t các Analysis Class Chec:9oints
Các bc trong Use-Case Analysis
 
YY GerormResponsibility
Znteraction Diagram
Class Diagram
<escribe =es9onsibilities
 
RegisterWorCoursesWorm
YY submit sche#ule%& YY #isplay course oerings%& YY #isplay sche#ule%& YY create sche#ule%& YY select 4 primary an# 2 alternate oerings%& YY #isplay blan; sche#ule%&
NNboun#aryOO
NNentityOO
CourseCatalogSystem
NNboun#aryOORegistrationController 
YY get course oerings%& YY submit sche#ule%& YY create sche#ule with oerings%&
NNcontrolOO
NNentityOO
status
YY mar; as selecte#%& YY mar; as cancelle#%& YY is selecte#%&
NNentityOO
Courseering
number F String † z1LLz startPime F Pime en#Pime F Pime #ays F num
YY a## stu#ent%& YY still open%& YY save%&
NNentityOO
NNentityOO
 
Maintaining Consistency? hat to 3oo: For  
 
sung !" t Use-case #i !$N use-case reali%ation
T&! các Class t' Use-Case eha(ior )h*n b Use-Case eha(ior (+ các Classs
#i !$N analysis class , t&! th.y M" t nhi/! ( c0a ch1ng M" t các Attribute (2 các Association 34ng giá 5quali6y7 các Analysis Mechanis!
849 nh.t các Analysis Class Chec:9oints
Các bc trong Use-Case Analysis
 
<escribe Attributes an Associations
 
ClassIame NNstereotypeOO
 Attribute F Pype † Znit…alue  Attribute F Pype † Znit…alue  Attribute F Pype † Znit…alue
Courseering NNentityOO
number FString†k1LL startPime F Pime en#PimeF Pime #aysF enumattribute
Tr"ng ana+ysis$ &hông n8n t2n nhi1u thi gian ch" vi#c 9ác 0.nh các attri5ute signature
=e(ie>? hat is an AttributeB
 
Fining Attributes
Cc thu0c tnhY7Xc 7i.m cQa cc class Cc thng tin 7c giJ l_i b8i cc class Cc k#anh t9 ;hng bi<n th6nh class
 
=e(ie>? hat is an AssociationB
" hnh ha m0t lin h, ngJ nghKa giJa cc th. hi,n %instances& cQa cc class
Simple association
NNentityOO Course
 
=e(ie>? hat are =olesB
Ihn v[t m6 m0t class k7ng vai trong association
Department hea#
Courseering NNentityOO
Sche#ule NNentityOO
remove stu#ent rom
3ác mu+ti!+e ass"ciati"n !h'i !h'n ánh các mu+ti!+e r"+e
DEa!9le? Multi9le Associations
=e(ie>? Multi9licity
24
L1

ˆhng m tE Duy nh5t m0t ‰ero hoXc nhiTu %manyf
unlimite#&
 
56n s7
L4
Courseering
DEa!9le? Multi9licity
3ai chi8u
Mt chi8u
Class1 Class2
Class1 Class2
=e(ie>? La(igability
 
9-:ay navigation
L4
L2
;holeaggregate part  
=e(ie>? hat is AggregationB
 
=hi c'm th;y nghi ng h>y ?@ng ass"ciati"n
association
aggregation
Association or AggregationB
 
.h/n $i0n Aggregation
Hn ngJ nghKa c th. cQa Aggregation S8 hJu 70c MuyTn %clusive wns&F Hoo; has Chapter 
C s@ ph` thu0c tn t_i %;hng c chapter n<u ;hng c boo;& ˆhng chia sj :6 thu0c tnh c 7/nh %m0t chapter ;hng th. chuy.n sang boo; ;hc&
S8 hJu %wns&F Car has Pire ˆhng chia sj ˆhng l6 thu0c tnh c 7/nh %c th. chuy.n tire sang m0t car ;hc&
C %+as&F Department has Stu#ent ˆhng c s@ ph` thu0c tn t_if c th. chia sj
 
Com)osition an$ Aggregation
 Aggregation cd bEn l6 b5t ;‹ Muan h, wholeŒpart IgJ nghKa c th. r5t md h Pdng ng vi ngJ nghKa z+asz v6 z"emberz "0t 7i tBng th6nh phn %part& c th. thu0c nhiTu hdn
m0t 7i tBng bao gm %whole& Composition l6 Aggregation m_nh hdn
P_i m0t th\i 7i.mf mi 7i tBng th6nh phn 59art7 chƒ c th. thu0c chƒ m0t 7i tBng bao gm 5>hole7
 
Aggregation an$ Com)osition
uan h, m‡n c th. ch5p nh[n
uan h, m‡n ;hng 7Bc phŠp
Cc Stu#ent c th. trong nhiTu Courseering I<u Courseering b/ hQyf cc Stu#ent ;hng b/ hQy
I<u Hoo; b/ af cc chdng %Chapter& trong Hoo; c=ng b/ a
Hoo; Chapter  
Association Class
"0t class k7Bc gn v6o m0t association Cha cc thu0c tnh cQa relationship "0t th. hi,n Y 1 lin;
Sche#uleeringZno
status
YY mar; as selecte#%& YY mar; as cancelle#%& YY is selecte#%&
NNentityOO
gra#e
YY is enrolle# in%& YY mar; as enrolle# in%& YY mar; as committe#%&
NNentityOO
1F GerormResponsibility
Fining =elationshi9s
 F Stu#ent
 F CourseCatalogSystem
12 YY #isplay course oerings% & 13 YY #isplay blan; sche#ule% &
 F Course Catalog
1 YY create sche#ule% & 2 YY select 4 primary an# 2 alternate oerings% &
11 YY g
 
et course oerings% & 21 YY create sche#ule with oerings% &
211 YY create with oerings% &
111 YY get course oerings%orSemester&
212 YY a## sche#ule%Sche#ule&
1111 YY get course oerings% &
 
'(am)%e" 45PC" 2in$ing Re%ationshi)s
RegisterWorCoursesWorm
Stu#ent L‡1
1 L‡
NNentityOO
1
RegisterWorCoursesWorm
YY create sche#ule %& YY #isplay course oerings %& YY #isplay blan; sche#ule YY select 4 primary an# 2 alternate oerings%&
NNboun#aryOO
RegistrationController 
 
CourseCatalogSystem NNboun#aryOO
NNentityOO
 
 F Courseering
 F Stu#ent
1124 YY any conlicts% &
 F RegisterWorCoursesWorm
11 YY
submit sche#ule% &
112 YY submit% & 111 YY save% & 1123 YY still open% &
112' YY a## stu#ent%Sche#ule&
1121 YY is selecte#% & 112( YY mar; as enrolle# in% &
1122 YY has pre-reMuisites%Courseering&
 
Sche#uleeringZno
status
YY mar; as selecte#%& YY mar; as cancelle#%& YY is selecte#%&
NNentityOO
NNentityOO
Courseering
number F String † z1LLz startPime F Pime en#Pime F Pime #ays F num
YY a## stu#ent%& YY cancel%& YY still open%& YY save%&
NNentityOO
Sche#ule
YY cancel%theering F Courseering& YY submit%& YY any conlicts%& YY create with oerings%&
NNentityOO
 
sung !" t Use-case #i !$i use-case reali%ation
T&! các Class t' Use-Case eha(ior )h*n b Use-Case eha(ior (+ các Classs
#i !$i analysis class , t&! th.y M" t nhi/! ( c0a ch1ng M" t các Attribute (2 các Association 34ng giá 5quali6y7 các Analysis Mechanis!
849 nh.t các Analysis Class Chec:9oints
Use-Case Analysis ;te9s
NNcontrolOO
Unif& Ana%&sis C%asses
 
Supplementary Speciication
Use-Case Analysis ;te9s
sung !" t Use-case #i !$i use-case reali%ation
T&! các Class t' Use-Case eha(ior )h*n b Use-Case eha(ior (+ các Classs
#i !$i analysis class , t&! th.y M" t nhi/! ( c0a ch1ng M" t các Attribute (2 các Association 34ng giá 5quali6y7 các Analysis Mechanis!
849 nh.t các Analysis Class Chec:9oints
 
)c*n ti+p,
Chec:9oints? Analysis Classes
Cc class c hBp l| ;hng Pn cQa cc class c phEn nh 7ng vai tr cQa chng Class c bi.u #i„n 1 single well-#eine# abstraction P5t cE cc attribute v6 responsibility c gn ;<t vi nhau vT mXt
 
Chec:9oints? Use-Case =eali%ations
P5t cE cc lung chnh v6 lung con 7x 7Bc 7iTu ;hi.n chaf bao gm cE cc tr\ng hBp ngo6i l,
 qx tm th5y t5t cE cc 7i tBng cn thi<t  qx phn phi m0t cch r r6ng t5t cE cc h6nh vi vT cc 7i
tBng cha Cc h6nh vi c 7Bc phn phi vT 7ng 7i tBng ;hng Cc interaction #iagrams nVm 8 7uf mi Muan h gwia chng
c r r6ng v6 ph] hBp ;hng
 
=e(ie>? Use-Case Analysis
"`c tiu cQa Use-Case Analysis l6 g "0t analysis class l6 g Cho bi<t tn v6 m tE vT 3 analysis
stereotype Use-case reali$ation l6 g " tE m0t v6i ho_t 70ng ;hEo st when 7Xt cc trch nhi,m
cho cc analysis class Hao nhiu interaction #iagram phEi 7Bc y #@ng trong giai
7o_n Use-Case Analysis
DEercise? Use-Case Analysis )art W
+xy cho bi<t cc ;hi ni,m sauF Cc ReMuirements artiactf 7Xc bi,t l6 7Xc tE b sung Cc cd ch< phn tch c th. Cc low o events interaction #iagram cho m0t use case c`
th. …i mi use case hxy c 7/nh cc #J ;i,n sauF
Cc thu0c tnh v6 cc mi Muan h, cQa Analysis class Cc cd ch< phn tch Analysis class
y #@ng cc lBc 7 sauF …GC class #iagramf cha cc analysis classf stereotype