When to use UML association classes?

Can I improve my design in these two diagrams below? If so, how?

I am confused by the use of association classes in my diagrams. Should I use them?

Picture 1

class diagram 1


Figure 2

class diagram 2

+8
uml erd class-diagram
source share
2 answers

For association classes, they only make sense if they represent associations with some behavior and state. Look at the article. He has nothing but a source, a goal and a personality. For such an association, you do not need a class, just use the usual association, which has all these properties. Your charts have more unnecessary association classes. Another important thing when using association classes is that each instance of this association class must have a unique source and target pair. For example, a comment cannot be identified only by the article and the user - one user can have a person in one article, and this is not allowed.

+5
source share

An association class is used to capture certain characteristics of the relationship between two classes. These characteristics do not apply to related classes, but relate to relationships between classes.

+6
source share

Source: https://habr.com/ru/post/651282/


All Articles