[TOC]
- Function Model
- Show the fuction of the system to user
- Diagram: Usage Diagram
- Object Model
- Show the structure of the system with concepts of object, attribute, operation, connection
- Diagram: Class Diagram, Object Diagram, Structure Diagram
- Dynamic Model
- Show the internal behavior of the system
- Diagram: Sequence Diagram, Activity Diagram, Status Diagram
- Diagram:
@startuml
<Content>
@enduml
- Line
- Solid:
--
- Dotted:
..
- Solid:
- Diamond
- Hollow:
o
- Solid:
*
- Hollow:
- Arrow
- Solic:
>
- Hollow:
|>
- Solic:
- Describe the coorperation between multiple objects by listing the messages between them in time order
<Object> -> <Object>: <Message>
: Message<Object> --> <Object>: <Message>
: Asynchronous Messagenote (left|right): <Content>
: Note last Message
@startuml
a --> b: How are you
note right: Greeting!
a -> a: I am thinking
b -> a: Fine
@enduml
- Describe the interaction between user and the system
- Actor:
actor <Actor>
- 执行者
- Rectangle
rectangle <Name>
{
<Content>
}
- Action:
<Actor> -> (<Action>)
<Actor> --> (<Action>)
@startuml
actor Customer
actor Chef
rectangle Restaurant{
Customer --> (Eat Food)
Customer --> (Pay For Food)
Chef --> (Cook Food)
}
@enduml
- Describe the logic process of the system
- Node
(*)
: Start / End Node"<Content>"
: Normal Node- Branch Node:
if "<Content>"
<Content>
else
<Content>
endif
- Flow
- Normal Flow:
<Node> -> <Node>: <Label>
<Node> --> <Node>
- Labeled Flow:
<Node> ->[<Label>] <Node>: <Label>
<Node> -->[<Label>] <Node>: <Label>
- Flow with direction
<Node> -<Direction>> <Node>: <Label>
<Node> -<Direction>-> <Node>: <Label>
- Direction
right
left
up
down
-> <Node>: <Label>
,--> <Node>: <Label>
: Equivalent to<LastNode> -> <Node>: <Label>
- Normal Flow:
@startuml
(*) --> "Buy 10 apples"
if "There is watermelon"
-->[true] "Buy 1 apple"
-right-> (*)
else
-->[false] "Something else"
--> (*)
endif
@enduml
- Describe the internal structure between the components of the system
- Heavily depends on hardware
- Node
- Dot:
<Content>
- Label:
[<Content>]
- Dot:
- Relate to:
<Node> - <Node>: <Label>
- Database:
database "<Label>" {
[<Node>]
...
}
@startuml
HTTP -up-> [Web Server]: Connect
[Web Server] - [App Server]
database "MySQL" {
[Database]
}
[App Server] - [Database]
@enduml
- Describe the changes between the statuses of a object
- Node
- Dot:
[*]
- Status:
<Status>
- Dot:
- Change
<Node> -> <Node>: <Label>
<Node> -<Direction>-> <Node>: <Label>
@startuml
[*] -> Ready: Start
Ready -> Running: Get CPU
Running -> Ready: Lost CPU
Running -down-> Block: IO, Sleep, Locked
Block -up-> Ready: IO Return, Sleep Over, Get Lock
Running -> [*]: Complete
@enduml
- Describe Classes and the Relationship between them
- Access Modifier
- Private:
-
- Protected:
#
- Package (Friendly):
~
- Public:
+
- Private:
- Class:
class <Class> {
<Feature>
}
- Class Modifier
- Abstract: `abstract`
- Interface:
interface List {
<Feature>
}
- Feature
- Field:
<Field>
- Method:
<Method>(<ArgumentList>)
- Field:
- Relationship
- Generalization:
<SubClass> --|> <SuperClass>
- Realization:
<Class> ..|> <Interface>
- Dependency
- Weak, Occasional Usage
- Code: Argument
- Usee Class used as an argument in a method of User Class
<UserClass> ..> <UseeClass>
- Association
- Strong Usage
- Code: Field
- Usee Class used as a field in User Class
<UserClass> --> <UseeClass>
<UserClass> -- <UseeClass>: <Label>
<UserClass> "<Quantifier>" -- "<Quantifier>" <UseeClass>: <Label>
- Aggregation
- Separatable Association between System and Component
- System has-a Component
- Each of them has its own life cycle
<System> o-- <Component>: <Label>
- Separatable Association between System and Component
- Composition
- Unseparatable Association between System and Component
- System contains-a Component
- Have same life cycle
- Stronger than Aggregation
<System> *-- <Component>
- Unseparatable Association between System and Component
- Generalization:
@startuml
class Dummy {
- Field1
# Field2
~ Method1
+ Method2
}
@enduml
@startuml
Son --|> Father
@enduml
@startuml
abstract class AbstractList
interface List
AbstractList ..|> List
@enduml
@startuml
Human ..> Book
@enduml
@startuml
class Human
class Brain
Human --> Brain
@enduml
@startuml
Company o-- Human
@enduml
@startuml
Human *-- Brain
@enduml