2013年11月20日 星期三

[ UML 文章收集 ] UML 之 User Case Diagram 的簡介

參考自 這裡 
Preface: 
Use Case Diagram 主要是描述一個系統或類別提供給外界之交互作用者的功能。簡單來說就是說明使用者如何使用系統的功能. 除此之外, 使用案例圖 (Use Case Diagram) 可以幫助我們從鳥瞰的視野綜觀系統的全貌: 
* 可以利用套件 (Package) 界定系統的設計範圍 (Boundary)。
* 避免過早涉及至細節 (Detail)。

那什麼是鳥瞰: 
* 從高處俯視低處。
* 對事實情況作概略的觀察。

利用使用案例圖,可以協助我們從 "鳥瞰" 的視野來看系統的外觀,避免從系統的內部來看 Use Case (這是許多 Developer 常犯的毛病)。同時,因為鳥瞰,所以,比較容易能看出系統的全貌、界定系統的範圍、區分系統的內與外 (這很重要,如此才能知道什麼該作,什麼不需作)。接著來看看如何撰寫 案例圖. 

User Case Diagram: 
案例圖 主要由以下幾個元件組成: 
- Use cases 
A use case describes a sequence of actions that provide something of measurable value to an actor and is drawn as a horizontal ellipse.

- Actors 
An actor is a person, organization, or external system that plays a role in one or more interactions with your system. Actors are drawn as stick figures.

- Associations 
Associations between actors and use cases are indicated in use case diagrams by solid lines. An association exists whenever an actor is involved with an interaction described by a use case. Associations are modeled as lines connecting use cases and actors to one another, with an optional arrowhead on one end of the line. The arrowhead is often used to indicating the direction of the initial invocation of the relationship or to indicate the primary actor within the use case. The arrowheads are typically confused with data flow and as a result I avoid their use.
下圖中Actor與Use Case間的連接線,我們稱為連結(Association),它表現出參與者(Actor)與系統使用案例之間的溝通 (Communicate ),可以在雙方之間傳送及接收訊息(Message)

- System boundary boxes (optional). 
You can draw a rectangle around the use cases, called the system boundary box, to indicates the scope of your system. Anything within the box represents functionality that is in scope and anything outside the box is not. System boundary boxes are rarely used, although on occasion I have used them to identify which use cases will be delivered in each major release of a system. Figure 2 shows how this could be done.
下圖中, 使用 矩形 (System boundary box) 框住每次 Release 包含的 User case(s)

- Packages (optional) 
Packages are UML constructs that enable you to organize model elements (such as use cases) into groups. Packages are depicted as file folders and can be used on any of the UML diagrams, including both use case diagrams and class diagrams. I use packages only when my diagrams become unwieldy, which generally implies they cannot be printed on a single page, to organize a large diagram into smaller ones.

Package是UML的構件 (construct),你可以用Package將Use Case或Class模型 (Model) 裏的Element,組合成 Package。Package 若用的好,可以簡化軟體設計的 Diagram。在 UML 裏,Package 是以資料匣的圖示表達。Package可用在所有的UML Diagram上,但最常是用在Use Case Diagram與Class Diagram。因為這兩種Diagram會一直成長,所以常需要適時切割.

另外 User cases 間可能也有相關聯, 此時可以使用 «extends» 與 «includes»
- Extends 
As the following figure illustrates, an extend relationship is displayed in the diagram editor as a dashed line with an open arrowhead pointing from the extension use case to the base use case. The arrow is labeled with the keyword «extend».


可以想成單一 Use Case 的功能被選擇性地插入到叧一個 Use Case,如下例,客戶瀏覽網站不見得會購買商品, "購買商品" 是 "瀏覽網站" 的擴充 User Case:

- Includes 
As the following figure illustrates, an include relationship is displayed in the diagram editor as a dashed line with an open arrow pointing from the base use case to the inclusion use case. The keyword «include» is attached to the connector.


可以想成單一Use Case的功能完全包含到叧一個 Use Case,如下例要確認訂單之前, 要先登入系統. "確認訂單" 包含 "登入系統":

不過以上兩個方法儘量少用,避免 Use Case Diagram 過度分支而複雜,原則上撰寫的 Use Case 一定要讓客戶跟開發人員都能看懂,否則這個 Use Case 就不是一個好的Use Case了

Use Case 不做的事情: 
Use Case並不是將所有的需求都描述進去,以下幾項是不會在Use Case中被撰寫的: 
- Implementation details 
不要描述實作細節,只講概要功能就好,例如不要說明資料將被存到Oracle資料庫,而說資料將被儲存就好.

- GUI Information 
不要講UI上的內容,例如按下『存檔』按鈕,避免到時候畫面作多國語言時,我們還要將Use Case改成多語內容...

- Internal processing unrelated to a stakeholder request 
不要講與使用者無關的系統內部作業,這一點跟第一項很像,就是不用講過多的邏輯內容在裡頭.

- Non-functional requirements 
不要講非功能性需求,例如系統每個操作要在2秒內回應,同時上線人數要達3000人等.


Supplement: 
Agile Modeling : UML 2 Use Case Diagrams 
[系統開發生命週期]Use Case Diagram概述 
從鳥瞰的觀點看 Use Case Diagram 
Elements of a Use Case Diagram 
Use Case Diagram 
Package於UML Diagram的應用 
VP Gallery > Use case diagram

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...