Before drawing a class chart, we must first clarify the Four Relationships in UML. There are four common relationships: Generalization, implementation, and Association ), dependency, which includes Aggregation and Composition in the association. In these relationships, they have a broken connection.
Before drawing a class chart, we must first clarify the Four Relationships in UML. There are four common relationships: Generalization, implementation, and Association ), dependency, which includes Aggregation and Composition in the association. In these relationships, they have a broken connection.
Before drawing a class chart, we must first clarify the Four Relationships in UML. There are four common relationships: Generalization, implementation, and Association ), dependency, which includes Aggregation and Composition in the association. In these relationships, they have a broken connection.
I. Concepts
[Generalization]: it is an inheritance relationship that represents a general and special relationship. It specifies how child classes feature all features and behaviors of the parent class. Arrows point to: solid line with a triangular arrow, and arrows point to the parent class.
[Implementation]: Relationship between a class and an interface, indicating that a class is the implementation of all features and behaviors of an interface. Arrow points: dotted line with hollow arrow, arrow points to interface.
[Association]: an association that allows a class to know the attributes and methods of another class. The arrow points to the solid arrow.
[Aggregation]: indicates that the entire object has partial objects. Arrow points to: hollow diamond + solid arrow.
[Combination]: a form of aggregation, which has a stronger ownership relationship, emphasizing that the overall and partial life cycles are consistent. Arrow points to: solid diamond + Implementation arrow.
[Dependency]: The semantic relationship between two things. A change in one thing (independent thing) affects another thing (dependent thing ). Arrow pointing: dotted arrow.
Ii. instance Introduction
[Generalization]: A bird belongs to an animal and has its own unique features.
[Implementation]: Dayan achieves the flying interface.
[Association]: penguins and climate. Penguins live in the South Pole. They need this climate to live. Penguins need to know about climate changes and climate patterns.
[Aggregation]: The computer and External keyboard can exist independently.
[Combination]: The relationship between birds and wings cannot exist independently.
[Dependency]: animals depend on oxygen, water, and food to survive.
Iii. pkcompetition
1. [aggregation] PK [combination]
Similarities: both represent the relationship of 'have'. difference: the length of life cycle.
[Aggregation]: indicates A weak 'havn' relationship. It indicates that object A can contain object B, and their lifecycles may be different, object A does not disappear with object B. The two can exist independently.
[Combination]: indicates A strong 'owner'. They are the relationship between parts and the whole. their lifecycles are the same. Object A disappears with object B, the two cannot exist independently.
Comparison of link strength: Combination> Aggregation
2. [generalization] PK [implementation]
Similarities: equivalent to inheritance. Subclass inherits the parent class, and the parent class extends the Child class.
Comparison of link strength: generalization = implementation
3. [Association] PK [dependency]
Similarities: all indicate dependencies. Difference: the strength of the relationship between classes and the length of time between classes.
[Join] indicates a strong relationship between classes. It indicates a "persistent" Relationship between classes. This relationship generally indicates an important relationship between businesses and needs to be saved, or "persistence" is required, or it needs to be stored in the database.
[Dependency] indicates a weak relationship between classes. It indicates a "temporary, transient" Relationship between classes, which does not need to be saved.
Comparison of link strength: Association> dependency
Comparison of link strength: generalization = implementation> combination> aggregation> association> dependency
Iv. Summary
When I first studied UML, I didn't know much about the four types of relationships. in c # And design patterns, I have mentioned four types of UML relationships and nine types of diagrams. I believe that through repeated learning, they can certainly deepen their understanding.