Adapted from Class diagrams
Type: classdiagram
e.g. -idCard : IdCard
Placed before name:
| Notation | Description |
|---|---|
+ |
Public |
- |
Private |
# |
Protected |
~ |
Package/Internal |
Placed after name (after "()" or return type):
| Notation | Description |
|---|---|
* |
Abstract e.g.: someAbstractMethod()* or someAbstractMethod() int* |
$ |
Static e.g.: someStaticMethod()$ or someStaticMethod() String$ or String someField$ |
Syntax: [classA][Arrow][ClassB]
e.g. classA <|-- classB
| Arrow | Description |
|---|---|
<-- |
Inheritance |
*-- |
Composition |
o-- |
Aggregation |
--> |
Association |
-- |
Link (Solid) |
..> |
Dependency |
..|> |
Realization |
.. |
Link (Dashed) |
Syntax: [classA][Arrow][ClassB]:LabelText
e.g. classA <|-- classB : label
Syntax: [Relation Type][Link][Relation Type]
e.g. Animal <|--|> Zebra
| Relation Type | Description |
|---|---|
<|-- |
Inheritance |
*-- |
Composition |
o-- |
Aggregation |
--> |
Association |
-- |
Link (Solid) |
..> |
Dependency |
..|> |
Realization |
.. |
Link (Dashed) |
| Link | Description |
|---|---|
-- |
Solid |
.. |
Dashed |
Syntax: bar ()-- foo
The interface (bar) with the lollipop connects to the class (foo).
e.g. namespace BaseShapes {
Syntax: [classA] "cardinality1" [Arrow] "cardinality2" [ClassB]:LabelText
e.g. Customer "1" --> "*" Ticket
| Cardinality | Description |
|---|---|
1 |
Only 1 |
0..1 |
Zero or One |
1..* |
One or more |
* |
Many |
n |
n (where n>1) |
0..n |
zero to n (where n>1) |
1..n |
one to n (where n>1) |
e.g. class Shape { <<interface>>
| Annotation | Description |
|---|---|
<<Interface>> |
Interface class |
<<Abstract>> |
abstract class |
<<Service>> |
service class |
<<Enumeration>> |
enum |
e.g. %% This whole line is a comment
e.g. note "This is a general note"
e.g. note for MyClass "This is a note for MyClass
classDiagram
direction LR
class ModelFactory {
+create(model_name) Model
}
class Context {
-Model model
+init(config)
+training()
}
class Model {
<<interface>>
+fit()
}
namespace torch {
class Module {
}
}
namespace sklearn {
class Estimator {
}
}
class TorchModel {
-Module module
+fit()
}
class SklearnModel {
-Estimator estimator
+fit()
}
Context --> Model : STRATEGY
Estimator *-- SklearnModel : ADAPTER
ModelFactory <-- Context : FACTORY
Model <|.. SklearnModel : implements
Model <|.. TorchModel : implements
Module *-- TorchModel : ADAPTER
classDiagram
direction LR
class ModelFactory {
+create(model_name) Model
}
class Context {
-Model model
+init(config)
+training()
}
class Model {
<<interface>>
+fit()
}
namespace torch {
class Module {
}
}
namespace sklearn {
class Estimator {
}
}
class TorchModel {
-Module module
+fit()
}
class SklearnModel {
-Estimator estimator
+fit()
}
Context --> Model : STRATEGY
Estimator *-- SklearnModel : ADAPTER
ModelFactory <-- Context : FACTORY
Model <|.. SklearnModel : implements
Model <|.. TorchModel : implements
Module *-- TorchModel : ADAPTER