UML常见的关系及使用Mermaid绘制UML类图
Notice: Undefined index: text in C:\zmofun\www\zmfWeb\usr\plugins\MarkdownParse\Parsedown.php on line 468
Notice: Undefined index: text in C:\zmofun\www\zmfWeb\usr\plugins\MarkdownParse\Parsedown.php on line 468
Notice: Undefined index: text in C:\zmofun\www\zmfWeb\usr\plugins\MarkdownParse\Parsedown.php on line 468
Notice: Undefined index: text in C:\zmofun\www\zmfWeb\usr\plugins\MarkdownParse\Parsedown.php on line 468
Notice: Undefined index: text in C:\zmofun\www\zmfWeb\usr\plugins\MarkdownParse\Parsedown.php on line 468
Notice: Undefined index: text in C:\zmofun\www\zmfWeb\usr\plugins\MarkdownParse\Parsedown.php on line 468
Notice: Undefined index: text in C:\zmofun\www\zmfWeb\usr\plugins\MarkdownParse\Parsedown.php on line 468
Notice: Undefined index: text in C:\zmofun\www\zmfWeb\usr\plugins\MarkdownParse\Parsedown.php on line 468
UML常见的类间关系及使用Mermaid绘制UML类图语法
泛化(Generalization)
继承关系,子类与父类的关系。
classDiagram
Parent <|-- Children
Parent : +int id
classDiagram
Parent <|-- Children
Parent : +int id
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal <|-- Zebra
Animal : +int age
Animal : +String gender
Animal: +isMammal()
Animal: +mate()
class Duck{
+String beakColor
+swim()
+quack()
}
class Fish{
-int sizeInFeet
-canEat()
}
class Zebra{
+bool is_wild
+run()
}
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal <|-- Zebra
Animal : +int age
Animal : +String gender
Animal: +isMammal()
Animal: +mate()
class Duck{
+String beakColor
+swim()
+quack()
}
class Fish{
-int sizeInFeet
-canEat()
}
class Zebra{
+bool is_wild
+run()
}
实现(Realization)
类与接口的关系。
classDiagram
class IFlyable{
<<interface>>
+flying()
}
IFlyable <|..Bat
Bat: +flying()
classDiagram
class IFlyable{
<<interface>>
+flying()
}
IFlyable <|..Bat
Bat: +flying()
组合(Composition)
整体与部分的关系,部分不能离开整体单独存在。
classDiagram
Computer *-- CPU
Computer *-- Mainboard
Computer *-- HardDisk
Computer *-- MemeryCard
classDiagram
Computer *-- CPU
Computer *-- Mainboard
Computer *-- HardDisk
Computer *-- MemeryCard
聚合(Aggregation)
整体与部分的关系,部分可以离开整体单独存在。
classDiagram
Company o-- Empolyee
classDiagram
Company o-- Empolyee
关联(Association)
一种拥有关系,一个类知道另一个类的属性和方法。
classDiagram
Reader "1..*" -- "1..*" Book
Book "1..*"--> "1"Author
classDiagram
Reader "1..*" -- "1..*" Book
Book "1..*"--> "1"Author
依赖(Dependency)
一种使用关系,一个类的实现需要另一个类的协助。
classDiagram
Animal..>Food
classDiagram
Animal..>Food
泛化=实现>组合>聚合>关联>依赖
classDiagram
classA --|> classB : Generalization
classM ..|> classN : Realization
classC --* classD : Composition
classE --o classF : Aggregation
classG --> classH : Association
classI -- classJ : Association
classK ..> classL : Dependency
classDiagram
classA --|> classB : Generalization
classM ..|> classN : Realization
classC --* classD : Composition
classE --o classF : Aggregation
classG --> classH : Association
classI -- classJ : Association
classK ..> classL : Dependency
评论已关闭