Скачать презентацию Writing Use Case Descriptions — Revisited Materials taken Скачать презентацию Writing Use Case Descriptions — Revisited Materials taken

1bcdb61b912492aafc1f49d5eb1190db.ppt

  • Количество слайдов: 40

Writing Use Case Descriptions - Revisited Materials taken directly from Use Case Modeling by Writing Use Case Descriptions - Revisited Materials taken directly from Use Case Modeling by Kurt Bittner and Ian Spence

Use Cases – Last Look at Detail… n Short description + bulleted outline and Use Cases – Last Look at Detail… n Short description + bulleted outline and major alternatives: Some use cases do not go beyond this n Flow of events is simple and team members agree on required behavior? n Perhaps time to simply prototype, confirm behavior, and move on. BUT: n Do developers (do analysis, design, implementation) feel n n comfortable enough to perform analysis, design, etc. ? ? ? Testers? Can create test cases to verify system meets intended goals? Technical Writers and user-education staff – who help the users understand how to use the system know enough? Support Staff, who will have to maintain and keep system running – feel they have enough info to do their jobs? ? ? If NO, we have more detail work to do…. .

How much detail is enough? n Brief descriptions? – great starting point. n May How much detail is enough? n Brief descriptions? – great starting point. n May not convey what system does for actors. n Must ensure that what the system must do is understood and has no possibility of mistake. n Most of the time, teams need more depth in use case descriptions (so not “useless cases”)

Some reasons for more detail… n May need additional documentation due to: n Document Some reasons for more detail… n May need additional documentation due to: n Document requirements for legal/contractual constraints n Info for team members who cannot attend all meetings with smes n Need to record decisions so as not to rely on memory and verbal communications… n Need to specify system to level to support testing.

More reasons… n The need for deeper and more-comprehensive description will also vary with More reasons… n The need for deeper and more-comprehensive description will also vary with the complexity and risk of system. People paying millions – need to feel comfortable (and may not with stories and undocumented requirements) n Systems on which lives depend require more… n n Use Case should be detailed enough to completely specify the inputs to the system (events initiated by actors and info the actors exchange with system) and the outputs of system.

More reasons for detail: n If dialog between actors is complex, system is complex, More reasons for detail: n If dialog between actors is complex, system is complex, and interactions will be complex. n Some systems may have simple external interactions but very complex internal behaviors. n Finally: (bottom line) How much detail is enough? n The use case must contain enough detail so that ALL stakeholders are satisfied that the system is defined in sufficient detail to allow the right system to be built. n Will use Withdraw Cash use case for rest of slides…. - a most significant use case; that is, one that has high priority and one that is architecturally significant. For this, a full description is required…

Describing Preconditions - again n Precondition: the state the system must be in or Describing Preconditions - again n Precondition: the state the system must be in or conditions that must be satisfied before use can be performed. n PRECONDITIONS NEEDED? n n May not be necessary, as it may be necessary to perform the use case at any time Only need to be defined in situations where the use cannot be performed unless certain conditions are true. Preconditions define these conditions. Think of preconditions as requirements that must be satisfied before use can start.

Preconditions – a warning n Preconditions should never be stated in terms of some Preconditions – a warning n Preconditions should never be stated in terms of some other use case having been performed. n If so, probably means you have broken use cases into chunks that are too small to have value by themselves. n Fix? Combine use cases, or n State the preconditions for one use case as the state in which the preceding use case will leave the system. n

Sample Preconditions from Withdraw Cash n The network connection to the banking system must Sample Preconditions from Withdraw Cash n The network connection to the banking system must be active n The system must have at least some currency that can be dispensed n The user must be authorized to perform the requested transaction

Describe Post-conditions - again n Defines the state that the system is in once Describe Post-conditions - again n Defines the state that the system is in once the use case has been performed. n Postconditions needed? Omit when result of use case is obvious, or n Omit when there is no significant state change in system. n n Postconditions only needed when the state is important to one of the actors for the use case, wuch as when the end state of the use case helps a stakeholder achieve a goal.

When to use Post-conditions n If completion of use case leaves system in a When to use Post-conditions n If completion of use case leaves system in a particular state that may be a precondition of another use case n If possible outcomes are not obvious enough to developers and testers or users to understand the result of performing the case. n Postconditions are conditions that are fulfilled when the use case is terminated no matter how the use case terminates.

Sample Post-conditions from Withdraw Cash n Example Post-conditions: n 1. The ATM has returned Sample Post-conditions from Withdraw Cash n Example Post-conditions: n 1. The ATM has returned the card and cash to the Customer and the withdrawal is registered on the customer’s account n The ATM has returned the card to the Customer and no withdrawal is registered on the customer’s account n The ATM has returned the card, but neither cash nor receipt to the Customer and the withdrawal is registered on the Customer’s account; the failure to dispense is registered in the logs…

Post-conditions - finally n Stick to simple statements of the state or condition the Post-conditions - finally n Stick to simple statements of the state or condition the system will be in when the use case completes. n If the use case achieves some stakeholder goal, be sure to call that out. n If system can be in different states depending on the path, these states should be enumerated.

Writing the Flow of Events n Usually proceeds from an outline n Use Case Writing the Flow of Events n Usually proceeds from an outline n Use Case must include enough detail so as not to constrain design. Consider: n Basic Flow n 1. The use case starts when the Customer inserts the bank card n 2. The system reads the card and requests the Customer to enter the Personal identification Number (PIN) n 3. The system presents a menu of choices. n 4. The Customer indicates a wish to withdraw cash n 5. The system requests the amount to be dispensed and the Customer enters the amount n 6. The system dispenses the desired amount of cash and ejects the card. n 7. The customer takes the cash and card. n 8. The use case ends.

Pay attention to What’s Behind the Screen n Must pay attention to what’s behind Pay attention to What’s Behind the Screen n Must pay attention to what’s behind the screen. Use Case does not stop at the ‘glass’ (UI) n VIP: A use case is much more than the user’s view of the system – simply a description of the user interface! n Much more than simply: n n The actor does…. The system does. The use case must provide much more than the glass (interface); it must provide the internal behavior (behind the screen).

n Must be enough detail so that you don’t have to trust the designer n Must be enough detail so that you don’t have to trust the designer to design the system so that it works correctly. n Many use cases only describe superficial aspects of the human machine interaction. n If the use case stops here, the use case is a “useless case. ” n n Need the specifics of the interchange The details are important components of the requirements of the system AND they must be captured! The internal details matter! If we are going to describe behavior, we must do it right!

Consider: Basic Flow – Withdraw Cash n n n n 1. The use case Consider: Basic Flow – Withdraw Cash n n n n 1. The use case starts when the Customer inserts the bank card 2. The system reads the card and obtains the bank number, the account number, and the Personal information Number (PIN). The system requests the Customer to enter the (PIN). The PIN can be up to six numbers in length and must not include any repeated digits. 3. The system compares the entered PIN to the PIN read from the card to determine if the PIN entered is valid. 4. If the PIN entered is valid, the system offers to the Customer the opportunity to withdraw cash. 5. The system requests the amount to be dispensed and the Customer enters the amount 6. The system checks to see if it has sufficient funds in its dispenser to satisfy the request. 7. The system ensures that the amount entered is a multiple of $5 and does not exceed $200. 8. The system contacts the Customer’s bank to determine if the amount requested can be withdrawn from the Customer’s bank account. 9. If the Customer has sufficient funds on hand, the system dispenses the desired cash. 10. The system logs the transaction with the following information: n The date/time of the transaction n The location of the ATM n The Customer’s bank number n The type of transaction n The amount of the transaction n The transaction identifier (for tracking within the inter-bank network). 11. The system ejects the card. 12. The Customer takes the cash, card, and receipt 13. The use case ends.

Discussion of basic flow… n Note how the description becomes much longer after we Discussion of basic flow… n Note how the description becomes much longer after we add the details of what the system does and what information is captured! n Too much information? n If you were paying someone to develop the system wouldn’t you want ot know exactly what the system was going to do? n n n Actually, use case is still lacking in detail. How to tell? Ask: “What does this mean? ” … Must continue until there is enough detail that all stakeholders are satisfied that the use case is ‘done’ and all of the inputs to the system and outputs from the system have been defined.

Full Description n n n n 1. The use case starts when the Customer Full Description n n n n 1. The use case starts when the Customer inserts the automated bank card 2. The system reads the card and obtains the bank number, the account number, and the Personal information Number (PIN). The system requests the Customer to enter the (PIN). The PIN can be up to six numbers in length and must not include any repeated digits. 3. The system queries the Customer’s bank to ensure that the Customer’s account is active at the financial institution identified by the inter-bank number. 4. The system prompts the Customer for the identification number, which the Customer enters. 5. The system validates the number entered by the Customer with the number read from the card. (Note: Alternate flows describing how to handle errors would be described below). 6. The system prompts the customer to enter the amount of the withdrawal. 7. The system indicates that the amount entered must be a multiple of $5. (Assume for the moment that this system allows only withdrawals and that the Customer has only one account. ) 8. The Customer enters the desired amount. 9. The system then determines whether it has sufficient funds on hand to dispense the requested amount. n n n n n It first checks to see if the total amount requested is greater than the amount on hand (Note: Insufficient net funds would be handled in an alternative flow, not shown here for brevity. ) If sufficient funds exist, it then checks to see if the requested amount can be dispensed with the denominations on hand. (Note that it is possible to have sufficient funds in total and still be unable to dispense funds; consider the case where the Customer has requested $35 but the system only has $40 in the form of two $20 bills. ) 10. The system contacts eh financial institution to see if the Customer has sufficient funds in the account. 11. The system begins a transaction with the financial institution and requests to withdraw the amount requested plus the transaction fee from the Customer’s account. 12. If the request is successful, the amount of the transaction fee is transferred to the organization owning the system. 13. The system then dispenses the requested amount to the Customer 14. The system closes the transaction with the financial institution. 15. The system logs the transaction with the following information: n The date/time of the transaction n The location of the ATM n The Customer’s bank number n The type of transaction n The amount of the transaction n The transaction identifier (for tracking within the inter-bank network). 16. The Customer’s banking card is ejected. 17. The use case ends when the Customer takes the banking card from the machine.

n Now the use case is still pretty simple (and haven’t shown alternatives). n n Now the use case is still pretty simple (and haven’t shown alternatives). n System only supports one kind of transaction. n But level of detail is getting realistic! n Could probably get a fairly good start on design n Common fear: adding detail; but if too vague, useless. Now, how to MANAGE the detail level…

Managing the Detail of a Use Case n Using the Glossary and Domain Model Managing the Detail of a Use Case n Using the Glossary and Domain Model n Writing ‘Named’ Subflows n Writing Optional, Alternative, and Exception Flows n Writing Special and Supplementary Specifications n Capturing Use Case Scenarios

 Managing the Detail of a Use Case - Using the Glossary and the Managing the Detail of a Use Case - Using the Glossary and the Domain Model n Lots of the Detail can be presented in other ways. n Glossary – one way to present terms w/o distracting the reader. n Terms and information needs: need defining n Examples: customer, customer’s bank, account, bank card, and PIN – if use case is to provide unambiguous description of behavior. n Why use Glossary n Avoid distraction and get in way of flow of events n Other use cases in system probably use same terms… n Start to create Glossary as soon as special terms start to appear. n Alphabetical. Bold terms in flow of events to indicate definitions are in Glossary.

Dictionary Contents n Definitions: n Account: … n Bank card … n Log: A Dictionary Contents n Definitions: n Account: … n Bank card … n Log: A permanent record used to prevent against data loss in the event of subsequent system failure. The log contains the following information for each transaction n The data and time of the transaction n The location of the ATM n The customer’s bank number n The type of transaction n The amount of the transaction n The transaction identifier (for tracking within the inter-bank network) n PIN … n Now, see how this changes the flow of events:

Evolving Flow of Events n 1. The use case starts when the Customer inserts Evolving Flow of Events n 1. The use case starts when the Customer inserts the automated bank card 2. The system reads the bank card and obtains the bank number, the account number, and the Personal information Number (PIN). The system requests the Customer to enter the (PIN). The PIN can be up to six numbers in length and must not include any repeated digits. 3. The system queries the Customer’s bank to ensure that the Customer’s account is active at the financial institution identified by the inter-bank number. 4. The system prompts the Customer for the identification number, which the Customer enters. 5. The system validates the number entered by the Customer with the number read from the card. (Note: Alternate flows describing how to handle errors would be described below). 6. The system prompts the customer to enter the amount of the withdrawal. 7. The system indicates that the amount entered must be a multiple of $5. (Assume for the moment that this system allows only withdrawals and that the Customer has only one account. ) 8. The Customer enters the desired amount. n ETC n n n n

In retrospect… n Don’t have to define these terms when we write the next In retrospect… n Don’t have to define these terms when we write the next use case. n If relationships exist between the concepts in the glossary, a domain model can be used… n The domain model would include definitions of things like customer, accounts, account types, etc. as the use cases are expanded to provide functionality that exercised these concepts. n Domain Model should never exist on its own, but rather should be used to augment the usecase descriptions (at least in the context of use case modeling)

 Managing the Detail of a Use Case - Writing “Named” Subflows n Very Managing the Detail of a Use Case - Writing “Named” Subflows n Very important behaviors – but perhaps that are not essential to n n understanding the basic flow of events. In Withdraw Cash: n 4. The system prompts the Customer for PIN n 5. The Customer enters the PIN n 6. The system validates the entered PIN with the PIN read from the card. These steps perform an essential function – validating the customer – but the details start to get in the way. Will have many such groups of steps that can be isolated, given a name, and moved into sections on their own. Called: named subflows, and are presented at the end of the Basic Flow in a section of the use called Subflows.

Sub. Flow Designation n Give subflow an active name and a number. n E. Sub. Flow Designation n Give subflow an active name and a number. n E. g S 1. Authenticate Customer not S 1. Customer Authentication… n Consider the Basic Flow ‘segment’ n n n 1. The use case begins when the actor Customer inserts the bank card. 2. The system reads the bank card information from the card 3. Perform Authenticate Customer 4. the system prompts the Customer to enter the amount of the withdrawal. (The remainder of the use case has been deleted for purposes of brevity) - and the Sub Flows:

The Subflows themselves n S 2. Assess Funds on Hand n 1. The system The Subflows themselves n S 2. Assess Funds on Hand n 1. The system determines whether it has sufficient funds on hand to dispense the requested amount. n n n A. The system checks to see if the total amount requested is greater than the amount on hand. B. The system checks to see if the requested amount can be dispensed with the denominations on hand. (Note that it is spossible to have sufficient funds in total and still be unable to dispense funds; consider the case where the Customer has requested $35 but the system only has $40 in the form of two $20 bills. ) 2. Resume at the next step

One more… n S 3. Conduct Withdrawal n 1. The system contacts the financial One more… n S 3. Conduct Withdrawal n 1. The system contacts the financial institution to see if the Customer has sufficient funds in the account. n 2. The system begins a transaction with the Customer’s bank and requests to withdraw the amount requested plus the transaction fee from the Customer’s account. n 3. The amount of the transaction fee is transferred to the organization owning the system. n 4. The system closes the transaction with the Customer’s bank. n 5. Resume at the next step.

Revisited Basic Course of Events n Use Case – Withdraw Cash (refined, incorporating glossary Revisited Basic Course of Events n Use Case – Withdraw Cash (refined, incorporating glossary terms) n n n 1. The use case begins when the actor Customer inserts the bank card. 2. The system reads the bank card information from the card. 3. Perform Authenticate Customer 4. The system prompts the Customer to enter the amount of the withdrawal. (Assume for the moment that this system allows only withdrawals and that the Bustomer has only one account. ) 5. The system indicates that the amount entered must be a multiple of $5. 6. The Customer enters the desired amount. 7. Perform Assess Funds on Hand 8. Perform Conduct Withdrawal 9. The system then dispenses the requested amount to the Customer 10. The system records a log entry for the transaction 11. The Customer’s banking card is ejected. 12. The use case ends when the Customer takes the bank card from the machine.

More… n Notice the creation of a few named subflows: n Simplifies the description More… n Notice the creation of a few named subflows: n Simplifies the description of the main flow n Given coherent meaning to several groups of steps – making them more understandable. n Use Case is simpler, more readable, and yet at the same time – more detailed. n Can actually recognize that a subflow will be necessary and merely ‘name’ them in the basic flow – and construct them later. n Great for repetitive descriptions with same use case. n Now, one more step: n Writing optional, alternative, and exception flows…

Managing the Detail of a Use Case Writing Optional, Alternative, and Exception Flows n Managing the Detail of a Use Case Writing Optional, Alternative, and Exception Flows n Optional, alternative, and exception flows are flows of events that occur when something other than the normal course of events has occurred. . n They are really all the same thing. n n Optional flows implies that behavior is optional and doesn’t always need to be performed Alternative flows imply some sort of alternate decision is taken, and Exception flows imply that something other than the ordinary has occurred. In ALL cases, we need to describe what happens when something occurs at a particular point in the use case. n Can be done in line if alternate steps are few, and short, and do not distract from understanding the main flow.

Representing Alternate Flows in Separate Sections. n As number of alternate flows grow, begin Representing Alternate Flows in Separate Sections. n As number of alternate flows grow, begin to distract from main flow. n Behavior of most systems tends to be dominated by handling alternative and exception behavior. n So, we need to describe these behaviors in separate sections of use case.

n Consider: system read bank card information from the card n If the system n Consider: system read bank card information from the card n If the system cannot read all the bank card information, then the system informs the Customer that the card cannot be read, the card is returned to the Customer, and the use case ends. n The system queries the Customer’s Bank to verify that the Customer information is correct. n If the Customer’s bank reports that the card has been stolen, it: n Confiscates the card and reports the confiscation to the Customer’s bank n Records a video of the Customer for future reference n Terminates the transaction n Reports to the Customer that n n n Card has been reported stolen Card has been confiscated Customer should contact their bank if there are questions. The use case then ends n Otherwise … [the use case continues…] n This additional behavior is important; don’t want to leave it out. n Need to set aside this exceptional behavior in an alternative flow leaving the basic flow to stand alone. n

Keep alternate flows separate…Example n n n n n Basic flow fragment… {Read Card} Keep alternate flows separate…Example n n n n n Basic flow fragment… {Read Card} The system reads the bank card info from card {Validate Card Information} The system queries the Customer’s bank to verify that the Customer identification is correct. Alternate Flows A 1. Handle Unreadable Bank Cafrd At {Read Card} if the system cannot read all the bank card information, then the system informs the Customer that the card cannot be read, the card is returned to the Customer, and the use case ends. A 2. Handle Stolen Bank Card. At {Validate Card Information} if the Customer’s bank reports that the card has been stolen, it: n n n Confiscates the card and reports the confiscation to the bank Records a video of the Customer for future reference Terminates the transaction Reports to the Customer that n Card has been reported stolen n Card has been confiscated n Customer should contact the bank if there any questions. The Use Case ends…. Consider what we have done…

n Naming Alternate Flows n Give it a name (as we did with subflows) n Naming Alternate Flows n Give it a name (as we did with subflows) n Name should reflect ‘goal’ alternative flow achieves. n E. g. , handle problems … report card stolen… n Use Extension Points to Target Alternate Behavior n Note: {Read Card} and {Validate Card Info} n Called ‘extension points’, because they allow the flow of events to be extended at the point at which they occur. n If we move optional, alternative, and exception behavior to a separate section, need a way to refer to the point at which the behavior will either be inserted or superseded the behavior presented in the basic flow. n Extension points allow us to refer to some section of behavior without resorting to using step numbers, which may change as the use case evolves n We removed the step numbers to highlight the use of extension points as textual reference mechanisms.

n Alternate flows can occur at more than one place. n An alternative flow n Alternate flows can occur at more than one place. n An alternative flow can occur at any time WHEN a particular event occurs – like failure n An alternative flow can terminate the use case currently being performed n A security requirement can be described by using the use case to describe what happens when an attempted security breach is detected. At completion: alternative resumes at the place where flow was interrupted UNLESS otherwise specified. . Don’t add extension point: {Resume Processing} or {Continue Transaction} Better to indicate a ‘section heading’ that describes what happens in the next set of steps. Can have alternate flows for alternate flows and named subflows…. (some other time).

Writing Special and Supplementary Specifications n Special and Supplementary – both non-functional, usually. n Writing Special and Supplementary Specifications n Special and Supplementary – both non-functional, usually. n Special Requirements – typically non-functional - that apply to one or more use cases or two a particular section of a use case. . n E. g. Performance of a particular use case or particular part of a use case. n If one or two use cases, can put in line; can bound with extension points. n If apply to system as a whole, capture in a requirements management tool, such as Rational Requisite Pro. n Makes them easy to manage but more difficult to refer to from some use cases… n Supplementary Requirements typically apply to all use cases and are similarly best handled by a requirements management tool. n Alternatively, supplementary requirements can be presented in a Supplementary Requirements document.

Capturing Use Case Scenarios n Scenario: specific instance of a use case consisting of Capturing Use Case Scenarios n Scenario: specific instance of a use case consisting of the basic flow plus none or other alternative flows…. n Important for several reasons: n Scenario will match the test cases one for one, providing an important source of information for testing the system. n Scenarios are what actually gets performed, so they are useful when discussion how the system will work in practice. This makes them useful for producing documentation, since the scenarios reflect how the system will be used. n Scenarios are useful for analysis and design, since they help the developers think about how the system will be used. n To document a scenario, give it a descriptive name and simply enumerate the flows the comprise the scenario.

Sample Scenario n Scenario: “Attempt to Use Stolen Card”: flows: “Basic Flow, ” “Handle Sample Scenario n Scenario: “Attempt to Use Stolen Card”: flows: “Basic Flow, ” “Handle Stolen Bank Card. ” n Scenario: “Out of Cash”: flows: “Basic Flow”, “Dispenser Empty” n Scenario: “Withdrawal Successful”: flow “Basic Flow. ” n When enumerating scenarios, it is not necessary to describe the inputs and outputs, those will have to be documented in the test cases anyway, so there is no need to document the test data in the scenarios. n The scenarios should be documented either as a separate section of the use case description or as part of the associated test cases.