Professional Documents
Culture Documents
2010-07-27
OLD_RD2 李宗沂
Agenda
• Introduction
• Structure Diagram
• Behavior Diagram
• Tools
• Discuss
Introduction
• History
• Three Amigos and OMG
• Usage of UML
• Meta Modeling
• Diagrams Overview (UML 2.0)
History
• Three Amigos
– Grady Booch
– James Rumbaugh
– Ivar Jacobson
• OMG (Object Management Group)
– UML® Resource Page http://www.uml.org/
Usage of UML
• Usage of UML
– 草稿
– 藍圖
– 程式語言
• Rule of UML
– 我們可以在一張特定圖中隱藏任何資訊不顯示
出來。
– 在一張圖中,不可以因為沒有看到某個東西就
做出任何推論。
Meta Modeling
Diagrams Overview (UML 2.0)
Structure Diagram
• Attribute ( 屬性 )
– visibility name : type [multiplicity] = default-
value { property-string }
• Operation ( 操作 )
– visibility name ( parameter-list ) : return-type
{ property-string }
– Parameter-list
• direction name : type = default-value
Class Diagram (Cont.)
• Property-string • Direction
– query – in
– modify – out
– readOnly – inout
– frozen
Class Diagram (Cont.)
Stereo Type
Static Type
Class Name
Note
Default Value
Multiplicity
Abstract
• Relationship ( 關係 )
– Dependency ( 依賴 , use-a)
– Association ( 關聯 )
• Unidirectional association ( 單向關聯 )
• Bidirectional association ( 雙向關聯 )
• Navigation ( 遊走性 )
– Aggregation ( 聚合 , has-a)
– Composition ( 合成 , owns-a)
– Generalization ( 一般化 , is-a)
• Realization ( 實現 )
Class Diagram (Cont.)
Unidirectional
Relation Name
Multiplicity
Bidirectional
Realization
• 使用時機
– 描述系統中各種物件的型態
– 描述各物件之間的靜態關係
– 描述物件的性質與操作
• 使用建議
– 不要畫出包含所有東西的模型,將重點放在關
鍵地方
Component Diagram
• 外部觀點 ( 黑箱觀點 )
– Required Interface ( 需求介面 )
– Provided Interface ( 可提供介面 )
– Artifacts ( 工作成果 )
• 內部觀點 ( 白箱觀點 )
– Realization ( 實現 )
• Port
Component Diagram (Cont.)
Component
Provided Interface
Port
Required Interface
Artifacts
Component Diagram (Cont.)
• 使用時機
– 描述元件之間的交互作用
– 將元件分解成更下層結構時
Deployment Diagram
Device Node
• 使用時機
– 呈現系統的實體配置情形
Behavior Diagram
• Fork ( 分岔節點 )
– 一個 Incoming Flow
– 多個 Outgoing Flow
• Join ( 會合節點 )
– 多個 Incoming Flow
– 一個 Outgoing Flow
Activity Diagram (Cont.)
Initial node
Flow
Edge Activity final
Fork
Join
• Subactivity ( 子活動 )
• Partition ( 分割 )
• Signal ( 信號 )
• Connector ( 連接器 )
• Flow Final ( 活動流結束節點 )
Activity Diagram (Cont.)
Subactivity
Activity Diagram (Cont.)
Partition Connector
Send Signal
Flow Final
Receive Signal
Activity Diagram (Cont.)
• 使用時機
– 描述程式邏輯、企業流程與工作流程
– 描述平行流程
– 描述物件橫跨幾個使用案例或執行緒的行為
State Machine Diagram
Final State
Initial Pseudostate
Transition
State
State Machine Diagram (Cont.)
Entry Activity
Do Activity
Substate
History Pseudostate
State Machine Diagram (Cont.)
• 使用時機
– 描述物件橫跨幾個使用案例的行為
– 了解控制物件行為
• 使用建議
– 不要對每個類別畫出狀態圖
Use Case Diagram
• Actor ( 參與者 )
• Use Case ( 使用案例 )
– Include ( 包含關係 )
– Extend ( 擴充關係 )
Use Case Diagram (Cont.)
Use Case
Actor
Use Case Diagram (Cont.)
• 使用時機
– 了解系統需求
• 使用建議
– 使用案例代表的是外部觀點,不一定會與系統
實作有關連
– 使用使用案例應該將重點放在說明文字而不是
圖上,說明文字才是使用案例價值所在
Sequence Diagram
• Participant ( 參與物件 )
• Lifeline ( 生命線 )
• Message ( 訊息 )
– Synchronous Message ( 同步訊息 )
– Asynchronous Message ( 非同步訊息 )
– Found Message ( 來源不明訊息 )
– Lost Message ( 目標不明訊息 )
Sequence Diagram (Cont.)
Life Line
Found Message
Return
Asynchronous Message
Destroy Message
Sequence Diagram (Cont.)
• 使用時機
– 描述數個物件在某個使用案例中的行為
– 描述物件間的合作關係
• 使用建議
– 要了解多個彼此可替代的互動情形時可以使用
CRC Card
CRC Card
• CRC
– Class 類別
– Responsibility 責任
– Collaborator 合作
Tools
• Free
– StarUML
• http://staruml.sourceforge.net/en/
– ArgoUML
• http://argouml.tigris.org/
– Astah* Community (JUDE)
• http://astah.change-vision.com/en/product/astah-
community.html
– Visual Paradigm - 智宇大大推薦
• http://www.visual-
paradigm.com/solution/freeumltool/
Discuss
Q and A