國立屏東大學 資訊工程學系 物件導向軟體工程
5. 需求分析
需求是「該被開發出來的規格」,因此需求最終必須導出規格(Specification)。規格即為軟體系統開發的指引(guideline),在後續系統設計與開發的過程中都必須遵循。需求工程( Requirements Engineering )是描繪出系統該有哪些功能的抽象層次規格並區分出其優先次序的工作,會出現在專案啟始和細部評估階段。需求不完整以及缺少使用者參與是導致專案失敗最主要的兩個原因,兩者的起因都是因為需求工程失敗所導致的。由於軟體系統之成敗取決於需求之滿足,良好的需求工程便成為軟體開發專案是否成功的重要關鍵。通常,需求工程包含需求擷取與需求分析兩大工作項目。
5.1 需求擷取
要瞭解需求必須從資料的搜集開始,由於資料的搜集主要是針對既有的系統或運作方式、流程等著手,所以這一部分的工作又稱為領域分析。
需求來自於
系統的直接使用者;
其他關鍵人員(例如,管理者、維護者、安裝人員);
與此系統互動之其他系統;
與此系統互動之硬體設備;
法律和管制限制;
技術限制;
商業目標。
5.1.1 領域分析與領域知識
領域分析是根據既有系統(或處理流程)及其開發的歷史、領域專家的知識、背後的理論,加以辨別,收集以及組織相關資訊的過程。
領域知識是指與特定領域相關的各項知識。
領域分析是系統開發前的預備知識。對於待開發產品之背景資料分析與蒐集、對於產品領域知識與操作越了解,越能在將來做出好的決策。
簡單地說就是也就是從各方面對目前既有的系統(或處理流程)進行資料蒐集。
領域專家
了解領域知識的好處
可以有效率的和客戶溝通
一般來說,從事領域分析的大多是系統分析師。有時候,也包括負責專案的專案經理,他是開發團隊與客戶間主要的對話窗口。但是嚴格說來,參與專案的每一個成員都必須對相關的領域有基本的認識與瞭解。因為這可以增進開發團隊與客戶之間的溝通。
了解企業既有的(As-is)處理流程,對於所要開發的系統會有實質的幫助。尤其對經常變動的企業邏輯 (business logic)或是商業規則(business rule)這方面尤其重要。
預留未來新系統的開發空間
5.1.2 需求擷取的方式
在擷取使用者需求之前,必須瞭解系統之潛在使用者及可能之人機互動。需求擷取常用的方式如下:
開會討論
開會討論與訪談的方式很類似。
開會討論是一種很有效率的資料蒐集方式。使用者代表與系統開發人員聚集一堂,將所知道的事實、觀念說出,讓所有與會人員一起相互溝通意見。
此方法的優點是較易獲得正確的資料,即使有不同的意見與觀念,經由眾人研究亦能加以修正。此外,亦可發揮腦力的效果。
缺點是安排溝通與協調較費時。
系統開發的過程中通常都會訂定有每週定期的開會時間表用以
檢視計畫的進度
確認工作細節
確認需求的正確性
各項相關任務的分派
人力資源的調度等等事項。
這些事項都是一個系統開發過程中的相當常見的變數,因此舉行定期的開會討論為一個有效的管理方式。
除了管理層面的定期開會討論之外,有時候它也用在技術面的討論上。
其他需求擷取的方式還包括有:
觀察
實地觀察所獲得的資料正確性會比查閱文件為高,亦能驗證所蒐集資料之正確性及補充不完整的資料,透過觀察可以獲得第一手的資料。
僅用觀察仍無法完整的反映出組織的真實情況與需求,例如被觀察者行為可能改變。
選擇正常與例外情況之時機或對象來作觀察,可獲得更多的資料。
問卷調查
當潛在使用者太多或分布太廣時,可考慮以問卷之方式擷取需求。
一般來說,問卷調查適合於大型企業或公眾資訊系統的設計,因為它所涉及的作業範圍或對象太廣,系統分析師無法逐一親自調查,故利用問卷方式來蒐集使用者需求較為可行。
設計一份好的問卷需有相當的練習與經驗,因為問卷上的問題是以文字靜態的表達,故問題之語意與邏輯必須很清楚且有條理。
問卷設計時也可以用各種不同的方法來問同一個問題,以觀察各種可能的答案。
正式問卷調查前需有先導測試。
經由先導測試之檢討與回饋可進一步修飾問卷,及早發現問卷可能之問題,對提升問卷之效能有很大之幫助。
抽樣調查
JAD會議。
小組討論
腦力激盪
5.2 需求分析
利用各種需求擷取的方式,你獲得了許多跟即將開發的系統相關的資料。這些資料可能很凌亂,雜亂無章,因此你必須將這些資料做整理與分析。
5.2.1 需求的種類
5.2.2 需求分析描述
5.2.3 Event Diagram
我們可以利用事件圖(Event Diagram)來思考辨識事件,如figure 1。
Fig. 1: 事件圖思考方式
除了一般的事件圖外,亦可使用CRUD圖。CRUD是由create、retrieve、update與delete的第一個字母所組成的縮寫,利用我們對資料的動作來捕捉事件,對於發覺隱性的功能或是使用者相當有用。
假設系統需要提供「使用者查詢音樂CD」、「使用者加入會員」、「使用者訂購音樂CD」 等等顯而易見的功能。我們可以就所發現之資料以及動作先在紙上嘗試著畫出如
figure 2之基本草圖:
Fig. 2: CRUD使用範例之1
Fig. 3: CRUD使用範例之2
5.2.4 Event Table
當你歸納出事件之後,可以將之紀錄於表格中,成為事件表。 事件表是用來記錄系統功能很有用的工具。不要擔心功能到底需要怎麼被實現出來,先把系統當成一個黑盒子。這樣做的好處是讓參與計畫的人員能將焦點放在系統高層次的觀點,從外部來看系統,而不是系統內部的運作情況。在很多的經驗中我們發現人們一般都把焦點放在系統的How, 而不是系統的What。這一點要值得注意。
事件列表格式 (可自訂)
事件表欄位說明
事件(Event):定義事件名稱,利用主詞+動詞+(受詞)的型式。
觸發器(Trigger):系統是如何得知事件的發生? 也就是指事件是如何被觸發的,例如特定的操作、特定資料內容的改變或輸入、特定的情況或條件或是特定時間。
來源(Source):資料來源
活動(Activity):事件發生時, 系統要執行的任務。活動要以動詞為開端。 例如:查詢 (Retrieve)…、更新(Update)…、產生(Create)…、取消(Delete)…。
回應(Response):如果需要的話,系統該產生什麼樣的輸出?
目的地(Destination):輸出到哪裡去。
[optional]優先權(Priority):此數值是指該需求在所有需求中的優先順序,普遍用來指定優先順序的是MoSCoW代碼[1]。
範例
一個線上購物系統,最明顯的事件就是”顧客下訂單”。我們可以分析出:事件名稱就是顧客下訂單。訂單是顧客下的,所以事件的來源來自於顧客。這個事件被觸發是因為訂單資料的到來,這是來自來源的一種要求。對於這個事件,系統應該要產生一筆新的訂單記錄,以記錄這個活動。所以,”產生一筆訂單”是活動的名稱。而”訂單編號”與所產生的訂單是這個活動的回應,此回應的目的地是負責出貨業務的部門。
另外,我們也假設系統必須在每個月5日產生前一月份的月報表。
Event | Trigger | Source | Activity | Response | Destination | Priority | Due Date |
顧客下訂單 | 資料(訂單資料輸入) | 顧客 | 在資料庫中產生一筆新訂單 | 1. 訂單編號 2. 訂單 | 出貨部門 | M | 2014/10/1 |
產生月報表 | 時間(每月5號) | 系統 | 依據資料庫內的資料產生前一個月份的報表 | 月報表 | 經理 | S | 每月5號 |
Tab. 1: Event Tabale範例
5.2.5 Glossary(詞彙表)
事件表固然記錄了系統所應提供的功能,可是,在任何事件的過程中都會牽涉到許多領域中的資料,概念。你要利用詞彙表將它紀錄、整理下來。詞彙表將在後面有很大的作用。對於不清楚的詞彙也要一併記錄下來。然後在與相關客戶人員討論以求得更進一步的了解
詞彙 | 解釋 |
登入資料 | 帳號、密碼 |
訂單 | 訂單包含有客戶資料、訂購項目 |
客戶資料 | 客戶編號、姓名、住址、電話、email |
訂購項目 | 編號、音樂CD摘要 |
音樂CD | 音樂CD摘要、曲目 |
音樂CD摘要 | 專輯名稱、演唱者、類型、單價、出版商 |
曲目 | 歌曲名稱、時間長度、作詞者、作曲者、歌詞 |
月報表 | (格式待查) |
客服建言 | 發言者、主題、內容、日期 |
Tab. 2: 詞彙表範例
5.3 軟體需求規格
建議至少應包含整體系統的描述與到功能性需求與非功能性需求,可使用下列項目表達:
* Context Diagram
* 功能性需求
* Event Table
* UML - Use Case Diagram/Form
* SysML Requirement Diagram
* 非功能性需求
* SysML Requirement Diagram
5.4 Context Diagrams
Fig. 4: 一個Context Diagrams範例
figure 4為一個簡單的示範,但在圖示方面可以參考以下的建議:
System and its boundary: Oval
Actors: Human mark
Information Flows : lines with arrows
Arrows from actor to the system represent actors supplying information to the system
Arrows from system to the actor represent the system returning information to the actor
Double-headed arrows represent both actor and system exchanging information with each other
The arrows should contain text with a brief description of the information flow being exchanged
Fig. 5: 採用標準圖示的Context Diagram範例
以我們欲開發的ezERD為例,其Context Diagram可以表達如figure 6。
Fig. 6: ezERD的Context Diagram
figure 6顯示了使用者可以透過ezERD完成ERD的設計,並可輸出對應的資料庫綱要給MySQL資料庫。
5.5 Use Case Diagrams
Introduced in 1986 by Ivar Jacobson.
An important aspect of the UML
Help us to find and record the system’s behavioral (i.e., functional) requirements (not all)
Use cases describe a system from the actors’ perspective
Use case modeling
Identify system boundaries
Identify system actors:
Identify actors’ goals for the system
Identify business events that fulfill these goals
Model (success/failure) scenarios for these events
Write use cases to document these scenarios
Fig. 7: Use Case Diagram範例
5.5.1 Actors
An actor is “anything outside of the system that exchanges information with it, including users and other systems”
An actor is “an entity that interacts with the system for the purpose of completing an event
Actors play roles (e.g., client, salesperson, etc.)
An actor is not a person, but the role the person plays
A person can have many roles (e.g., user, manager)
And a role can be played by many persons (e.g., clients)
An actor can be a person or any (non-human) external entity (e.g., external system, device, external service organization) that the system will interact with
Types:
Personalities
Initiator: an actor who initiates events that trigger a use case (e.g., customer places an order)
External Server: an actor who provides a service to the system in the use case (e.g., query to a credit bureau to process a loan)
Receiver: an actor that receives information from the use case (e.g. IRS receives corporate tax return)
Facilitator: an actor that supports another actor’s interaction with the system (e.g., data entry clerks)
Actor Specification Cards which are defined as follows:
Actor Specification |
Actor Name: |
Type: (Primary/Secondary) | Personality: (initiator, external, receiver or facilitator) | Abstract: (Yes/No) |
Role Description: |
Actor Goals: (no need to fill this box for secondary actors) |
Use Case Involved with: (events that fulfill goals above; a goal will map to one or more use cases; a use case will map to one or more primary actor goals; no need to fill this box initially, only after use cases have been identified. |
Actor Specification |
Actor Name: Customer |
Type: Primary | Personality: initiator | Abstract: No |
Role Description: A customer is a person who has opened an account with the bank. The customer is the main reason for the existence of ATM machines. The customer interacts with the ATM to obtain convenient banking services at times when he/she cannot or is not convenient to obtain such services at the bank's premises. |
Actor Goals: | * Withdraw cash |
* Deposit funds |
* Make transfers |
* Inquire balances |
Use Case Involved with: | * Withdraw funds |
* deposit funds |
* manage account (make transfers, inquire balances) |
以ezERD為例,其使用者的Actor Specification可以寫做如下:
Actor Specification |
Actor Name: 使用者 |
Type: Primary | Personality: initiator | Abstract: No |
Role Description: 使用者為ezERD軟體的主要操作者,透過使用ezERD軟體,使用者可以繪製新的ERD、並與MySQL資料庫連結建立對應的資料庫綱要 |
Actor Goals: | * 繪製ERD |
* 連結MySQL伺服器 |
* 產生關聯式資料庫綱要 |
Use Case Involved with: | * ERD編輯 |
* MySQL資料庫連結 |
* 產生資料庫綱要 (含database選擇或建立) |
5.5.2 Use Cases
Is a complete set of artifacts of the use cases describing how actors interact with a system
Artifacts are any diagrams, models, cards, tables, documents and other descriptions that define and describe the system requirements
We will focus on two artifacts initially: diagrams and textual descriptions
The use case model should fully describe the entire “functional scope” of the application
Each use case within a use case model has its own smaller functional scope, which encompasses the functional responsibility of the use case
Collectively, all use cases combined should encompass the entire functional scope of the system (i.e., the whole is equal to the sum of the parts).
Related Artifacts
Context Diagram: not really part of a formal Use Case Model, but it is often included because it provides a great high level representation of the system
Use Case Diagram: shows the system boundary, actors and all use cases involved
Activity Diagrams: use case descriptions are sometimes diagrammed using this type of UML artifact
Use Cases: text descriptions that describe all possible scenarios of how actors interact with the system to deliver the required system functionality (i.e., functional scope).
Finding Use Cases
List all goals for all primary actors
Identify business events that will accomplish these goals (e.g., apply for a loan, withdraw cash)
Each business event or goal that yields observable value to a primary actor maps to a use case
Actor specification cards are useful for this
Goals are not always fulfilled by the system (e.g. ATM has no cash), so Use Cases need to model “sunny day” (i.e., optimistic) and “rainy day” (i.e., pessimistic) scenarios.
5.5.3 Use Case Diagram Symbols
System boundary: rectangle
Use cases: Ovals
Actors: Human mark
Relationships: Line with or without arrows
Meaning of the direction of arrows
Arrows have a different meaning in Use Case Diagrams than in context diagrams
Direction of arrows do not represent information flow.
Instead, they indicate who initiates the use case.
Fig. 8: 使用Use Case的範例1
Fig. 9: 使用Use Case的範例2
Fig. 10: ezERD的Use Case圖
5.5.4 Use case modeling process
Fig. 11: Use case modeling process
5.5.4.1 Initial Use Cases
Prepare a list of all use cases based on the actor goals identified in all Primary Actor Specification cards
Per the UP, not all use cases need to be identified at this stage; more use cases will probably be discovered during the elaboration phase
For each Use Case, fill in a Use Case form to record all the information you have about the responsibilities of that use case
Focus on general descriptions initially (i.e., Initial Use Cases)
Per the UP, you will add details later as you further elaborate the use cases
Use Case Form
Use Case ID | |
Use Case | |
Actors | |
Description | |
Priority | (only if you have this information at this point) |
Non-Functional Requirements | (only if noteworthy at this point) |
Assumptions | (only if noteworthy at this point) |
Source | |
Example:
Use Case ID | UC-100 |
Use Case | Withdraw Funds |
Actors | (P) Customer |
Description | The customer inserts card in the ATM, logs in with a pass code, and makes a selection from the available choices to withdraw funds. Once in the funds withdrawal screen, the customer is prompted to enter the amount to withdraw. After the amount is entered, the system will check for availability of funds for that customer. Provided that funds are available, the system will dispense the amount requested in cash and then debit that amount in the customer’s bank account records. |
Priority | High |
Non-Functional Requirements | Cash dispensed within 10 seconds after amount is entered |
Assumptions | Customer speaks English |
Source | Bank’s Operational Procedures Manual |
Example for the ezERD:
Use Case ID | ezUC-001 |
Use Case | ERD繪製 |
Actors | (P) 使用者 |
Description | 使用者可以透過ezERD軟體進行ERD的繪製。 |
Priority | Medium |
Non-Functional Requirements | 必須採用WYSIWYG的方式繪製的向量的ERD,且必須符合ERD的規則。 |
Assumptions | 假設使用者不需要存檔的功能 |
Source | 使用者訪談(附訪談記錄) |
5.5.4.2 Base Use Cases
Fig. 12: Base use cases與 initial use case
The base use cases describe the specific behaviors and interactions that take place between actors and the system, within the scope of the use case.
An base use case provides a complete description of the normal set of primary interactions between the actors and the system, within a use case
i.e., “sunny day”, “success” or “optimistic” scenarios only, i.e., the scenarios that fulfill actors’ goals
No need to model “rainy day”, “failure” or “pessimistic” scenarios yet – this comes later
Purpose
Understand the primary interactions between the system and user as well as system behaviors in the use case
Provide detailed description of “sunny day” scenarios
Begin to identify/document exceptions or alternative scenarios, but don’t model these yet
Begin to identify non-functional requirements and assumptions associated with the use case
Document the priority of each use case in the development effort
Contents
Use Case ID | |
Use Case | |
Actors | |
Description | (brief) |
Pre-conditions | |
Flow of Events | 1. |
1.1 |
1.2 |
2. |
Post-conditions | |
Alternative Flows | (briefly described) |
Priority | (High, Medium or Low) |
Non-Functional Requirements | (only those associated with this use case, if any) |
Assumptions | |
Outstanding Issues | |
Source | |
Use Case ID | UC-100 |
Use Case | Withdraw Funds |
Actors | (P) Customer |
Description | Customer logs in, selects withdraw funds, enters an amount and receives cash and receipt |
Pre-conditions | Welcome screen is on |
Flow of Events | 1. Customer slides card in and out |
2. Machine prompts customer for password |
3. Customer enters password |
4. System authenticates customer |
5. System presents user with a choice menu |
6. Customer selects Withdraw Funds option |
7. System asks customer to select account |
8. Customer selects account |
9. System asks customer for amount to withdraw |
10. Customer enters amount |
11. System dispenses cash and prints receipt |
12. System logs customer out |
Post-conditions | Welcome screen is back on |
Alternative Flows | Customer may not be authenticated; customer may not have sufficient funds; machine may not have enough cash |
Priority | High |
Non-Functional Requirements | Cash dispensed within 10 seconds after amount is entered |
Assumptions | Customer speaks English |
Source | Bank’s Operational Procedures Manual |
以我們的ezERD為例,其base use case如下:
Use Case ID | ezUC-001 |
Use Case | ERD繪製 |
Actors | (P) Customer |
Description | Customer logs in, selects withdraw funds, enters an amount and receives cash and receipt |
Pre-conditions | Welcome screen is on |
Flow of Events | 1. Customer slides card in and out |
2. Machine prompts customer for password |
3. Customer enters password |
4. System authenticates customer |
5. System presents user with a choice menu |
6. Customer selects Withdraw Funds option |
7. System asks customer to select account |
8. Customer selects account |
9. System asks customer for amount to withdraw |
10. Customer enters amount |
11. System dispenses cash and prints receipt |
12. System logs customer out |
Post-conditions | Welcome screen is back on |
Alternative Flows | Customer may not be authenticated; customer may not have sufficient funds; machine may not have enough cash |
Priority | High |
Non-Functional Requirements | Cash dispensed within 10 seconds after amount is entered |
Assumptions | Customer speaks English |
Source | Bank’s Operational Procedures Manual |
5.5.4.3 Fully Elaborated Use Cases
Elaborating on the Base Use Cases
Base use cases provide an excellent perspective of the system, but we need to add more detailed information about the system’s behavior to complete the analysis
Base Use Cases describe “sunny day” scenarios that fulfill the goals of the actor(s) involved (e.g., get cash)
During the execution of a use case there will be variations such as alternatives and exceptions that occur as a result of the interactions between the actors and the system.
Elaborated Use Cases also include “rainy day” scenarios, some of which don’t fulfill actors’ goals (e.g., insufficient funds, no cash in the ATM machine)
Later, we will also add Included and Extended Use Cases, and also Generalizations
What is added in the Elaborated Use Case
More details about the activities performed during the flow of events of a Base use case, as needed
Conditional and alternative flow of events to document exception and alternative processing as needed
Splitting the Base Use Case into two or more narrowly focused Elaborated Use Cases, when the Base Use Case is too broad or complex
Adding non-functional requirements specifically associated with the Use Case (e.g., performance, capacity, availability, security), as needed
Adding constraints imposed on the Use Case (e.g., must operate on Linux
OS and Oracle database)
Conditional vs. Alternative Flow of Events
The are both very similar
When to use Conditional Flow of Events:
Variations are key to understanding the Use Case
Variations occur frequently
Variations are short and simple
When to use Alternative Flow of Events:
Conditional Flow of Events
As more elaborated functionality is discovered, conditional logic can be a useful approach to represent the functional complexity
Be sure to keep the conditional logic at a manageable level of detail.
The objective is to understand the functionality, not to write the software code
Use IF statements to initiate conditional flows; Ex.:
7. If ATM machine is out of cash
7.1 Notify customer of no cash availability
7.2 Log customer out
7.3 Notify ATM service group
Fig. 13: 從base use case延展至elaborated use case (with conditional flow of events)
Use Case ID | |
Use Case | |
Actors | |
Description | |
Pre-conditions | |
Flow of Events | 1. |
2. If xx go to 8 (conditional flow) |
3. |
4. If yy go to Use Case UC 101-A1 (alternative flow) |
5. Etc |
Conditional Flows | 8. (list/describe relevant events and return to 3) |
9. Etc. |
Post-conditions | |
Alternative Flows | (if simple, briefly describe it; if long or complex, move to a separate Use Case) |
Priority | (High, Medium or Low) |
Non-Functional Requirements (only those associated with this use case, if any) | |
Assumptions | |
Outstanding Issues | |
Source | |
Use Case ID | |
Use Case | |
Actors | |
Description | |
Pre-conditions | |
Flow of Events | 1. |
2. If xx (conditional flow listed when it occurs) |
2.1 |
2.2 |
3. |
4. if yy go to Use Case UC 101-A1 |
5. etc |
Post-conditions | |
Alternative Flows | (if simple, briefly describe it; if long or complex, move to a separate Use Case) |
Priority | (High, Medium or Low) |
Non-Functional Requirements | (only those associated with this use case, if any) |
Assumptions | |
Outstanding Issues | |
Source | |
Use Case ID | UC-100 |
Use Case | Withdraw Funds |
Actors | (P) Customer |
Description | Customer logs in, selects withdraw funds, enters amount, gets cash |
Pre-conditions | Welcome screen is on |
Flow of Events | 1. Customer slides card in and out |
2. Machine prompts customer for password |
3. Customer enters password |
4. If password is incorrect |
4.1 go back to step 2 |
4.2 if password is incorrect 3 times |
4.2.1 Retain card and notify user |
4.2.2 go to step 13 |
5. System authenticates customer |
6. System presents user with a choice menu |
7. Customer selects Withdraw Funds option |
8. System asks customer to select account |
9. Customer selects account |
10. System asks customer for amount to withdraw |
11. Customer enters amount |
12. System dispenses cash and prints receipt |
13. System logs customer out |
Post-conditions | Customer is logged out an welcome screen is back on |
Alternative Flows | Customer may not have sufficient funds; machine may not have enough cash |
Priority | High |
Non-Functional Requirements | Cash dispensed within 10 seconds after amount is entered |
Assumptions | Customer speaks English |
Source | Bank's Operational Procedures Manual |
Fig. 14: alternative use cases
Normally there are several possible variations, alternatives and exceptions that can occur when a use is executed. Ex.:
These alternative behaviors can represent significant functionality, so it is necessary to model the implications of these alternatives
We do this in Alternative Use Cases
Which describe the Flow of Events that are triggered when such exceptions occur in the Use Case
An alternative Use Case is not independent; it is tied to the Use Case that originated it
Alternative Flow of Events
Documents the specific behaviors that will occur in an Alternative Use Case
An alternative Use Case can involve such things as:
A different processing option based on user input
A decision taken within the use case flow of events, or
An exception condition that triggers a different set of behaviors
Not all alternative events need to go in separate Use Cases; they can be documented quickly and briefly in the base use case description
The Alternative Use Case has a new field indicating the “Insertion Point” (where it starts executing in the Base Use Case
Use Case Document for Alternative Flows
Use Case ID | (same ID as the base Use Case ID, but with suffix A1, A2, etc.; e.g., UC 101-A1) |
Use Case | |
Actors | (same as Base Use Case’s Actors) |
Description | |
Insertion Point | (step in Base Use Case where this alternative flow should be inserted) |
Pre-conditions | (clearly indicate under which conditions trigger the alternative flow) |
Alternative Flow of Events | 1. |
2. |
3. |
Conditional Flows | (within the Alternative flow) |
Post-conditions | |
Priority | |
Non-Functional Requirements | |
Assumptions | |
Outstanding Issues | |
Source | |
Example:
Use Case ID | UC-100 |
Use Case | Withdraw Funds |
Actors | (P) Customer |
Description | Customer logs in, selects withdraw funds, enters amount, gets cash |
Pre-conditions | Welcome screen is on |
Flow of Events | 1. Customer slides card in and out |
2. Machine prompts customer for password |
3. Customer enters password |
4. If password is incorrect |
<html> </html> 4.1 If card used was reported stolen execute UC-100-A1 |
<html> </html> 4.2 go back to step 2 |
<html> </html> 4.3 If password is incorrect 3 times |
<html> </html> 4.3.1 Retain card and notify user |
<html> </html> 4.3.2 go to step 13 |
5. System authenticates customer |
6. System presents user with a choice menu |
7. Customer selects Withdraw Funds option |
8. System asks customer to select account |
9. Customer selects account |
10. System asks customer for amount to withdraw |
11. Customer enters amount |
12. System dispenses cash and prints receipt |
13. System logs customer out |
Post-conditions | Welcome screen is back on |
Alternative Flows | Customer may not have sufficient funds; machine may not have enough cash. |
Priority | High |
Non-Functional Requirements | Cash dispensed within 10 seconds after amount is entered |
Assumptions | Customer speaks English |
Source | Bank's Operational Procedures Manual |
Use Case ID | UC-100-A1 |
Use Case | Withdraw Funds Alternative for Stolen Card Use |
Actors | (P) Customer |
Description | Notify security when use of a stolen card is detected |
Insertion Point | UC-100, flow 4.1 |
Pre-conditions | User entered incorrect password and card had been reported stolen |
Flow of Events | 1.Immediately notify bank security |
2.Place a call to local authorities |
3.Take multiple pictures with ATM camera |
4.Interact with user as if it were a normal transaction |
5.Disable cash dispensing functions temporarily |
6.Introduce processing delays to keep customer distracted |
7.Retain card |
8.Timeout if user stops interacting with ATM 30 seconds or more |
9.Timeout if new user inserts a legitimate card |
10.System logs customer out |
Post-conditions | Welcome screen is back on |
Alternative Flows | |
Priority | High |
Non-Functional Requirements | |
Assumptions | System has local authority notification feature |
Source | Bank’s Operational Procedures Manual |
5.5.4.3.1 Extended Use Cases
When developing a use case model, there will be times when significant behaviors will be identified, which extend the behavior of the base use cases
Extended behaviors are commonly used to model:
Future extensions to the system (it is a good development practice to include all known future extensions in the analysis model)
Extended versions of the system (e.g., “Premium”, “Professional”)
Possible extensions, which can be added or removed later
These additional behaviors are documented using Extend Relationships and Extended Use Cases
Advantages of the Extend Approach
Helps represent the system’s extended behavior in the Use Case without cluttering, complicating or enlarging the base flow of events.
Rather, significant extensions can be drawn out and represented separately
The Base Use Case flow does not have to be re-written and the Use Case Model does not need to be re-drawn to reflect this new behavior.
As new extensions are discovered they can be added to the model
As extensions are discarded they can be easily removed from the model
Adding Extended Use Cases
The Base Use Case is extended at specific points in its Flow of Events named “Extension Points”
The extending behaviors are executed at these points when the required conditions for extension are met
Control is returned to Base Use Case at the same point in Flow of Events where the extension was triggered
Fig. 15: Extended Flows
Fig. 16: Extended Use Case 1
Fig. 17: Extended Use Case 2
Use Case ID | (same as the base Use Case ID, but with suffix E1, E2, etc.; e.g., UC 101-E1) |
Use Case | |
Actors | (same as Base Use Case’s Actors) |
Description | |
Extended Use Case | |
Extension Point | (step in Base Use Case where this extension occurs) |
Guard Conditions | (precondition in the Extended Use Case that triggers the extension) |
Alternative Flow of Events | 1. |
2. |
3. |
Conditional Flows | (within the Extended flows) |
Post-conditions | |
Priority | |
Non-Functional Requirements | |
Assumptions | |
Outstanding Issues | |
Source | |
Use Case ID | UC-100-E1 |
Use Case | Print bank statement for a fee |
Actors | (P) Customer |
Description | Allows customer to print a bank statement with balances and transactions in the last 30 days for a $1 fee |
Extended Use Case | UC-100 Withdraw Funds |
Extension Point | UC-100; after flow step 12 |
Guard Conditions | Statement printing option is implemented and enabled |
Flow of Events | 1. Ask customer if he/she would like a printed bank statement |
2.If customer says yes |
2.1 Notify customer of a $1 charge for this service |
2.2 Prompt customer to continue or cancel |
2.3 If customer selects continue |
2.3.1 Print statement |
2.3.2 Debit $1 from customer’s account |
2.3.3 Display thank you note |
Post-conditions | Return to UC-100 and continue on flow step 13 |
Alternative Flows | |
Priority | Low |
Non-Functional Requirements | Statement must print within 20 seconds |
Assumptions | |
Source | Bank’s Operational Procedures Manual |
5.5.4.4 Refactoring and Included Use Cases
The concept of “refactoring” comes from software programming – as software gets corrected, maintained, updated, etc. its code often becomes disorganized and/or suboptimal
Re-factoring: “is a technique to restructure code in a disciplined way” – Martin Fowler
It involves re-organizing the software code without changing its functionality, to make it easier to understand and maintain
Refactoring is applied today to many aspects of system development, not just programming
In Use Cases, it involves the “Included” Use Cases
Included Use Cases
Included Use Cases provide a way to model similar behaviors that can be used across multiple use cases
As the Use Case is elaborated, you may identify flow of events that are repeated in several Use Cases
You can extract them into generic “Included” Use Cases, and then “Include” them whenever you need them
Examples:
Advantages of Included Use Cases
Identify commonalities among use cases
Manage redundancy within the use case model
Facilitate change in the use case model – when things change in the Included case, you only need to make the necessary changes once
Begin to assemble Included Use Case “Libraries” of common behaviors that can be re-used in other projects
Fig. 18: Included Use Case
* Notation for the Included Relationship
Fig. 19: Included Relationship 1
Fig. 20: Included Relationship 2
Using Included Use Cases
Identify all Included Use Cases with the prefix “IUC” instead of “UC”
Indicate in the Base Use Case the point in the Flow of Events where the included use case is included
In the Included Use Case, document all Base Use Cases that use that Included Uses Case
Use Case ID | (use IUC suffix instead of UC; e.g., IUC 001) |
Use Case | |
Description | |
Including Use Cases | (list Use Cases that use in this included Use Case) |
Pre-conditions | |
Alternative Flow of Events | 1. |
2. |
3. |
Conditional Flows | (within the included flows) |
Post-conditions | |
Priority | |
Non-Functional Requirements | |
Assumptions | |
Outstanding Issues | |
Source | |
Use Case ID | UC-100 |
Use Case | Withdraw Funds |
Actors | (P) Customer |
Description | Customer logs in, selects withdraw funds, enters amount, gets cash |
Pre-conditions | Welcome screen is on |
Flow of Events | 1. Include IUC-001 Log in and Authenticate Customer |
2. If not successful, go to step 10 |
3. System presents user with a choice menu |
4. Customer selects Withdraw Funds option |
5. System asks customer to select account |
6. Customer selects account |
7. System asks customer for amount to withdraw |
8. Customer enters amount |
9. System dispenses cash and prints receipt |
10. System logs customer out |
Post-conditions | Welcome screen is back on |
Alternative Flows | Customer may not have sufficient funds; machine may not have enough cash. |
Priority | High |
Non-Functional Requirements | Cash dispensed within 10 seconds after amount is entered |
Assumptions | Customer speaks English |
Source | Bank's Operational Procedures Manual |
Use Case ID | IUC-001 |
Use Case | Login and Authenticate Customer |
Description | Customer logs, gets authenticated, card is checked against stolen reports |
Including Use Cases | UC-101 Withdraw Funds; UC-102 Deposit Funds; UC-103 Other transactions |
Pre-conditions | ATM has detected a card in the slot |
Flow of Events | 1. Customer slides card in and out |
2. Machine prompts customer for password |
3. Customer enters password |
4. If password is incorrect |
<html> </html> 4.1 If card used was reported stolen execute IUC-001-A1 |
<html> </html> 4.2 go back to step 2 |
<html> </html> 4.3 If password is incorrect 3 times |
<html> </html> 4.3.1 Retain card and notify user |
<html> </html> 4.3.2 System logs customer out and ends this transaction |
5. System authenticates customer |
Post-conditions | System is back on the next flow step right after this included case was invoked |
Alternative Flows | |
Priority | High |
Non-Functional Requirements | Authentication should take place within 20 seconds after password entered |
Assumptions | Customer speaks English |
Source | Bank's Operational Procedure Manual |
5.5.4.5 Generalization Relationships
“implies that the child Use Case contains [i.e., inherits] all the attributes, sequences of behavior, and extension points defined in the parent use case, and participates in all relationships of the parent use case.”
Like classical generalization and inheritance
A more powerful version of “Include”
Notations
Fig. 21: Generalized Use Case 1
Fig. 22: Generalized Use Case 2
5.5.5 Important Rules about Use Case Models
Alternative Use Cases don’t need to be diagrammed –> they an integral part of the originating Use Case (if you decide to diagram them, apply the same rules for Extended Use Cases)
Use Cases should not connect with other Use Cases in the diagram
Actors should not connect with other Actors in the diagram
Only Actors connect (interact) with Use Cases
But there are 3 exceptions:
Extended Use Cases connect with their respective extending Use Cases
Included Use Cases connect with the Use Cases that include them
Use cases can connect to other use cases and actors can connect to other actors when there is a “generalization” relationship
Extended and Included Use Cases may or may not connect directly with Actors
Extended and Included Use Cases don’t “stand alone” à they are always associated with another use case.