Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use UML Association Classes?

Can I improve my design on these 2 diagrams below? If so, how?

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

Figure 1

class diagram 1


Figure 2

class diagram 2

like image 834
Zabahey Avatar asked Jan 20 '11 07:01

Zabahey


2 Answers

For association classes, they make sense only if they represent associations with some behaviour and state. Look at Article'sSubject. It has nothing more than source, target and identity. You don't need a class for such a association, just use plain association, which has all those properties. There are more such unnecessary association classes in your diagrams. Another important thing when using association classes is that every instance of that association class should have unique source and target pair. For example Comment is not identifiable just by Article and User - one user may have man ycomments on one article and that is not allowed.

like image 167
Gabriel Ščerbák Avatar answered Oct 22 '22 05:10

Gabriel Ščerbák


An association class is used to capture certain characteristics of an association between two classes. These characteristics do not belong to the classes being associated but instead belong to the relationship between the classes.

like image 31
Paws Avatar answered Oct 22 '22 05:10

Paws