From c04fdd250c752b22417df51d3bf3aae6c79df2b4 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Sun, 3 Oct 2021 15:10:15 -0700 Subject: [PATCH 1/2] Document two-way relations and fix relationship docs for class diagrams --- docs/classDiagram.md | 37 +++++++++++++++++++++++++++++++++++-- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/docs/classDiagram.md b/docs/classDiagram.md index 2dd92b2b4..d27bef53f 100644 --- a/docs/classDiagram.md +++ b/docs/classDiagram.md @@ -241,7 +241,7 @@ To specify the visibility of a class member (i.e. any attribute or method), thes A relationship is a general term covering the specific types of logical connections found on class and object diagrams. ``` -[classA][Arrow][ClassB]:LabelText +[classA][Arrow][ClassB] ``` There are different types of relations defined for classes under UML which are currently supported: @@ -310,7 +310,7 @@ classM ..|> classN : Realization classO .. classP : Link(Dashed) ``` -## Labels on Relations +### Labels on Relations It is possible to add a label text to a relation: @@ -332,6 +332,39 @@ classE o-- classF : association ``` +### Two-way relations + +Relations can go in multiple ways: + +``` +classDiagram + Animal <|--|> Zebra +``` + +Here is the syntax: + +``` +[Relation Type][Link][Relation Type] +``` + +Where `Relation Type` can be one of: + + +| Type | Description | +| ---- | ----------- | +| <\| | Inheritance | +| \* | Composition | +| o | Aggregation | +| > | Association | +| \|> | Realization | + +And `Link` can be one of: + +| Type | Description | +| ---- | ----------- | +| -- | Solid | +| .. | Dashed | + ## Cardinality / Multiplicity on relations Multiplicity or cardinality in class diagrams indicates the number of instances of one class linked to one instance of the other class. For example, one company will have one or more employees, but each employee works for just one company. From 93a1961762873c348f75ba0f971794cbe3c03c33 Mon Sep 17 00:00:00 2001 From: Yash Singh Date: Sun, 3 Oct 2021 15:11:57 -0700 Subject: [PATCH 2/2] Add another relation type --- docs/classDiagram.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/classDiagram.md b/docs/classDiagram.md index d27bef53f..f55982506 100644 --- a/docs/classDiagram.md +++ b/docs/classDiagram.md @@ -356,6 +356,7 @@ Where `Relation Type` can be one of: | \* | Composition | | o | Aggregation | | > | Association | +| < | Association | | \|> | Realization | And `Link` can be one of: