[2/24/2020] - I should update this page using examples from mexm-base, and rewrite the prose. A lot of this prose is taken from [1], but the examples aren't very clear. I should probably also implement this into python3 stub classes, so people who read this become familiar with it.
The declaration of classes is pretty simple
@startumlclass class_1class class_2@endumlf two classes in a model need to communicate with each other, there must be a link between them, and that can be represented by an association (connector).
Association can be represented by a line between these classes with an arrow indicating the navigation direction. In case an arrow is on both sides, the association is known as a bidirectional association.
We can indicate the multiplicity of an association by adding multiplicity adornments to the line denoting the association. The example indicates that a Student has one or more Instructors:
@startumlclass Studentclass Teacher'a single student can associate with multiple teachersStudent "1..N" -- Teacher: learns from >@endumlThis example indicates that every Instructor has one or more Students:
@startumlclass Studentclass Teacher'a teacher has multiple studentsStudent "1..N" -- Teacher: learns from <@enduml@startuml' this example doesn't work, need to look how to do thisclass Studentclass TeacherStudent "1..N" -- "1..N" Teacher: teacher <Student "1..N" -- "1..N" Teacher: learns from >@endumlWe will go over the three types of association connectors: association, aggregation, and composition. These examples are taken from [1]
Aggregation and Composition are subsets of association meaning they are specific cases of association. In both aggregation and composition object of one class "owns" object of another class. But there is a subtle difference.:
[Figure 1] Composition of a Person class from three classes: Head, Hand and Leg
@startumlclass Personclass Headclass Handclass LegPerson *-- HeadPerson *-- HandPerson *-- Leg@enduml[Figure 2] Composition of a Person class from three classes: Head, Hand and Leg
@startumlclass EngineInspectionclass Carclass Engineclass WheelCar o-- EngineCar o-- WheelEngineInspection *-- Engine @endumlGeneralization is the term that we use to denote abstraction of common properties into a base class in UML. The UML diagram's Generalization association is also known as Inheritance. When we implement Generalization in a programming language, it is often called Inheritance instead. Generalization and inheritance are the same. The terminology just differs depending on the context where it is being used.
We should be more specific and use the composition link in cases where in addition to the part-of relationship between Class A and Class B - there's a strong lifecycle dependency between the two, meaning that when Class A is deleted then Class B is also deleted as a result
[1] Visual Paradigm. "UML Association vs Aggregation vs Composition"