2009 04 Phantichuse-case

  • Published on
    19-Jul-2015

  • View
    162

  • Download
    0

Embed Size (px)

Transcript

<p>Gio trnh Phn tch v thit k hng i tng bng UML</p> <p>Phn tch Use-Case</p> <p>Phn tch Use-Case Dng Anh c</p> <p>1</p> <p>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</p> <p>Phn tch Use-Case Dng Anh c</p> <p>2</p> <p>Use-Case Analysis trong ng cnh</p> <p>Architectural AnalysisReview the Architecture Architecture Reviewer</p> <p>Architect</p> <p>Architectural Design</p> <p>Describe Concurrency</p> <p>Describe Distribution</p> <p>Use-Case Analysis Designer Use-Case Design</p> <p>Subsystem Design Review the Design</p> <p>Design Reviewer</p> <p>Class Design</p> <p>Phn tch Use-Case Dng Anh c</p> <p>3</p> <p>Tng quan Use-Case Analysis</p> <p>Software Architecture Glossary Use-Case Document Modeling Guidelines Supplementary Specifications</p> <p>Analysis Classes</p> <p>Use-Case Realization (identified)</p> <p>Use-Case Analysis</p> <p>Use-Case Realization (developed)</p> <p>Use-Case ModelPhn tch Use-Case Dng Anh c</p> <p>Analysis Model (optional)4</p> <p>Design Model</p> <p>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</p> <p>5</p> <p>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</p> <p>6</p> <p>Supplement the Use-Case Description</p> <p> H thng hin th mt danh sch cc lp hc (course offerings).Phn tch Use-Case Dng Anh c</p> <p> 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.</p> <p>7</p> <p>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</p> <p>8</p> <p>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( )</p> <p>AttributesOperations</p> <p>Phn tch Use-Case Dng Anh c</p> <p>9</p> <p>Review: Use-Case RealizationUse-Case Model Design Model</p> <p>Use Case</p> <p>Use-Case Realization</p> <p>Sequence Diagrams</p> <p>Collaboration Diagrams</p> <p>Use Case Class Diagrams10</p> <p>Phn tch Use-Case Dng Anh c</p> <p>Tm cc Class t Use-Case Behavior Ton b hnh vi ca mt use case phi c phn b v cho cc analysis class</p> <p>Phn tch Use-Case Dng Anh c</p> <p>11</p> <p>Th no l mt Analysis Class?</p> <p> Use-case behavior coordination</p> <p>System boundary</p> <p>System information</p> <p>Phn tch Use-Case Dng Anh c</p> <p>12</p> <p>Analysis Classes: A First Step Towards Executables</p> <p>Use Cases</p> <p>Analysis Design Classes ElementsUse-Case Analysis</p> <p>Source Code</p> <p>Exec</p> <p>Phn tch Use-Case Dng Anh c</p> <p>13</p> <p>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</p> <p>Ph thuc mi trngPhn tch Use-Case Dng Anh c</p> <p>14</p> <p>Vai tr ca Boundary Class</p> <p> Customer </p> <p>M hnh ha s tng tc gia system v mi trng ca nPhn tch Use-Case Dng Anh c</p> <p>15</p> <p>V d: Tm cc Boundary Class Mt boundary class cho 1 cp actor/use case</p> <p>Student</p> <p>Register for Courses</p> <p>Course Catalog System</p> <p> RegisterForCoursesForm</p> <p> CourseCatalogSystem</p> <p>Phn tch Use-Case Dng Anh c</p> <p>16</p> <p>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!</p> <p>Phn tch Use-Case Dng Anh c</p> <p>17</p> <p>Th no l mt Entity Class? Cc tru tng ha then cht ca systemAnalysis class stereotypeGlossary </p> <p>Use Case</p> <p>Business-Domain Model Architectural Analysis AbstractionsPhn tch Use-Case Dng Anh c</p> <p>c lp mi trng18</p> <p>Vai tr ca Entity Class</p> <p> Customer </p> <p>Lu tr v qun tr cc thng tin trong systemPhn tch Use-Case Dng Anh c</p> <p>19</p> <p>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</p> <p>Phn tch Use-Case Dng Anh c</p> <p>20</p> <p>V d: Candidate Entity Class Register for Courses (Create Schedule)</p> <p>Student CourseOffering</p> <p>Schedule</p> <p>Phn tch Use-Case Dng Anh c</p> <p>21</p> <p>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()</p> <p>Generalization Relationship</p> <p>Checking</p> <p>Savings GetInterest() Withdraw()</p> <p>SubclassesWithdraw()</p> <p>Phn tch Use-Case Dng Anh c</p> <p>22</p> <p>Finding Generalization: Generalization of ClassesStock Savings Checking</p> <p>Tng qut hn</p> <p>RealEstate</p> <p>Bond</p> <p>Asset</p> <p>BankAccount</p> <p>Security</p> <p>RealEstate</p> <p>Savings</p> <p>Checking</p> <p>Stock</p> <p>Bond</p> <p>Phn tch Use-Case Dng Anh c</p> <p>23</p> <p>Finding Generalization: Specialization of Classes</p> <p>Asset</p> <p>Asset</p> <p>BankAccount</p> <p>Security</p> <p>RealEstate</p> <p>Savings</p> <p>Checking</p> <p>Stock</p> <p>Bond</p> <p>Chuyn bit hn</p> <p>Phn tch Use-Case Dng Anh c</p> <p>24</p> <p>Example: Generalization (Chia s ng ngha)Part-timeStudent Full-timeStudentname address studentID gradDate</p> <p>Khng c s tng qut ha</p> <p>name address studentID numberCourses</p> <p>Student</p> <p>C s tng qut ha</p> <p>name address studentID</p> <p>FulltimeStudent gradDate</p> <p>ParttimeStudent</p> <p>maxNumCourses</p> <p>Phn tch Use-Case Dng Anh c</p> <p>25</p> <p>Th no l mt Control Class? Nh iu phi cc hnh vi ca Use-case Ch mt control class cho mt use case</p> <p>Use Case</p> <p>Analysis class stereotype</p> <p>Ph thuc use-case, c lp mi trng</p> <p>Phn tch Use-Case Dng Anh c</p> <p>26</p> <p>Vai tr ca Control Class</p> <p> Customer </p> <p>iu phi cc hnh vi ca use-casePhn tch Use-Case Dng Anh c</p> <p>27</p> <p>V d: Tm cc Control Class Mt control class cho mt use case</p> <p>Student</p> <p>Register for Courses</p> <p>Course Catalog System</p> <p> RegistrationController</p> <p>Phn tch Use-Case Dng Anh c</p> <p>28</p> <p>Example: Summary: Analysis Classes</p> <p>Student</p> <p>Register for Courses</p> <p>Course Catalog System</p> <p>Use-Case Model Design Model RegisterForCoursesForm RegistrationController CourseCatalogSystem</p> <p> Student</p> <p> Schedule</p> <p> CourseOffering</p> <p>Phn tch Use-Case Dng Anh c</p> <p>29</p> <p>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</p> <p>30</p> <p>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</p> <p>Sequence Diagrams Use Case</p> <p>Collaboration Diagrams</p> <p>Use-Case Realization</p> <p>Phn tch Use-Case Dng Anh c</p> <p>31</p> <p>Interaction Diagrams Generic term that applies to several diagrams that emphasize object interactions Sequence Diagram Time oriented view of object interaction</p> <p>Sequence Diagrams</p> <p> Communication Diagram (or Collaboration Diagram) Structural view of messaging objectsCommunication DiagramsPhn tch Use-Case Dng Anh c</p> <p>32</p> <p>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</p> <p>(cn tip)Phn tch Use-Case Dng Anh c</p> <p>33</p> <p>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</p> <p>Phn tch Use-Case Dng Anh c</p> <p>34</p> <p>The Anatomy of Sequence DiagramsClient Object</p> <p>Supplier Object</p> <p>:Client</p> <p>:Supplier</p> <p>Object Lifeline1: PerformResponsibility y l mt script mu</p> <p>Reflexive Message</p> <p>Message</p> <p>1.1: PerformAnother Responsibility</p> <p>Hierarchical Message Numbering Focus of ControlPhn tch Use-Case Dng Anh c</p> <p>35</p> <p>Register for Courses Use Case Basic flow: Create a Schedule1. The Student selects "create schedule." 2. The system retrieves a list of available course 3. 4.</p> <p>5. 6.</p> <p>offerings from the Course Catalog System. The system displays a blank schedule form. The Student selects 4 primary course offerings and 2 alternate course offerings from the list of available offerings. Once the selections are complete the Student selects "submit." H thng to mt lch hc cha nhng hc phn sinh vin ng k. Sinh vin kim tra v xc nhn lch hc, Submit Schedule c thc thi.36</p> <p>Phn tch Use-Case Dng Anh c</p> <p>Analysis Classes</p> <p>Phn tch Use-Case Dng Anh c</p> <p>37</p> <p>Example: Sequence Diagram: Student : RegisterForCoursesForm : RegistrationController : CourseCatalogSystem : Course Catalog : Schedule : Student</p> <p>1. // create schedule( ) 1.1. // get course offerings( ) Student wishes to create a new schedule 1.1.1. // get course offerings(forSemester) 1.1.1.1. // get course offerings( ) 1.2. // display course offerings( )</p> <p>A list of the available course offerings for this semester are displayed</p> <p>A blank schedule is displayed for the students to select offerings</p> <p>1.3. // display blank schedule( )</p> <p>2. // select 4 primary and 2 alternate offerings( ) 2.1. // create schedule with offerings( )</p> <p>2.1.1. // create with offerings( ) 2.1.2. // add schedule(Schedule)</p> <p>At this, point the Submit Schedule subflow is executed.Phn tch Use-Case Dng Anh c</p> <p>38</p> <p>Example: Sequence Diagram (cont.): RegisterForCoursesForm : Student : RegistrationController : Schedule : : CourseOffering PrimaryScheduleOfferingInfob : Student</p> <p>1. // submit schedule( ) 1.1. // submit schedule( )1.1.1. // save( )</p> <p>1.1.2. // submit( ) 1.1.2.1. // is selected?( ) [ is selected ] 1.1.2.2. // has pre-requisites(CourseOffering) Repeat for all primary course offerings. An attempt is made to register the student for all selected course offerings 1.1.2.3. // still open?( ) 1.1.2.4. // any conflicts?( ) [ has pre-requisites, course offering open, and no schedule conflicts ] 1.1.2.5. // add student(Schedule) 1.1.2.6. // mark as enrolled in( )</p> <p>Phn tch Use-Case Dng Anh c</p> <p>39</p> <p>Example: Use case Withdraw of ATMUse case: WithdrawIdentify Nouns</p> <p>Actor: Client Purpose: To allow the client to withdraw money Pre-conditions: User already logged-in Post-conditions: Amount is deducted from users account Main flow:1) Client initiates this usecase by selecting 'withdraw' 2) System displays all the accounts related to the Card and prompts to select any one. 3) Client selects one account. 4) System prompts for the amount (fast cash or )40</p> <p>Client User Account Amount Money Card Cash</p> <p>Phn tch Use-Case Dng Anh c</p> <p>Sequence Diagram Use case Withdraw</p> <p>: Client</p> <p>: WithdrawUI</p> <p>: WithdrawControl</p> <p>: Card</p> <p>: Account</p> <p>1: // select withdraw( ) 2: // get list accounts( ) 3: // get accounts( ) 4: // get info( )</p> <p>5: // display account( )</p> <p>6: // select account( ) 7: // enter money( ) 8: // withdraw( ) 9: [enough money] // withdraw( )</p> <p>Phn tch Use-Case Dng Anh c</p> <p>41</p> <p>The Anatomy of Collaboration DiagramsClient Object Link:Client :Supplier 1: PerformResponsibility</p> <p>Supplier Object</p> <p>MessagePhn tch Use-Case Dng Anh c</p> <p>42</p> <p>Example: Collaboration Diagram1.2. // display course offerings( ) 1.3. // display blank schedule( )</p> <p>1. // create schedule( ) 2. // select 4 primary and 2 alternate offerings( ) : RegisterForCoursesForm</p> <p>: Course Catalog: Student 1.1. // get course offerings( ) 2.1. // create schedule with offerings( ) 1.1.1.1. // get course offerings( )</p> <p>1.1.1. : RegistrationController // get course offerings(forSemester) : CourseCatalogSystem 2.1.1. // create with offerings( ) 2.1.2. // add schedule(Schedule) : Student : Schedule</p> <p>Phn tch Use-Case Dng Anh c</p> <p>43</p> <p>Example: Collaboration Diagram (cont.)1. // submit schedule( ) : RegisterForCoursesForm</p> <p>: Student 1.1. // submit schedule( )</p> <p>1.1.2.4. // any conflicts?( )</p> <p>1.1.1. // save( ) 1.1.2. // submit( ) : RegistrationController</p> <p>1.1.2.3. // still open?( ) 1.1.2.5. // add student(Schedule) : Schedule : CourseOffering</p> <p>1.1.2.1. // is selected?( ) 1.1.2.6. // mark as enrolled in( ): PrimaryScheduleOfferingInfob</p> <p>1.1.2.2. // has pre-requisites(CourseOffering)</p> <p>: Student</p> <p>Phn tch Use-Case Dng Anh c</p> <p>44</p> <p>One Interaction Diagram Not Good EnoughBasic Flow Alternate Flow 1 Alternate Flow 2 Alternate Flow 3</p> <p>AF3 AF1 AF2</p> <p>Alternate Flow 4</p> <p>Alternate Flow 5</p> <p>Alternate Flow n</p> <p>Phn tch Use-Case Dng Anh c</p> <p>45</p> <p>Collaboration Diagrams Vs Sequence Diagrams Collaboration Diagrams Ch ra cc mi quan h b sung cho cc tng tc Trc quan ha tt hn cc mu cng tc Trc quan ha tt hn cc hiu ng tc ng ln mt i tng c D s dng hn trong cc vn cn gii quyt tp th Sequence Diagrams Ch ra r rng chui cc thng ip Trc quan ha tt hn ton b lung s kin Tt hn cho cc c t real-time v cho cc scenario phc tp</p> <p>Phn tch Use-Case Dng Anh c</p> <p>46</p> <p>Exercise: Use-Case Analysis, Part 1 Hy xy dng: Use-Case Model, c bit l cc use-case flows of events Cc tru tng ha/class then cht Hy xc nh cc thng tin sau cho mt use case c th: Cc analysis class, cng vi chng l: Brief descriptions Stereotypes Responsibilities Cc collaboration cn thit ci t use case</p> <p>(cn tip)Phn tch Use-Case Dng Anh c</p> <p>47</p> <p>Exercise: Use-Case Analysis, Part 1 (tt) Vi mt use case c th, hy thit lp: Use-case realization interaction diagram cho ti thiu mt trong cc use-case flows of events</p> <p>Phn tch Use-Case Dng Anh c</p> <p>48</p> <p>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 Classs 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</p> <p>49</p> <p>Describe Responsibilities Trch...</p>