13

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

harpun
  • 4,022
  • 1
  • 36
  • 40
Zabahey
  • 328
  • 1
  • 3
  • 16

2 Answers2

7

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.

Gabriel Ščerbák
  • 18,240
  • 8
  • 37
  • 52
  • thank you for your suggestion. I will improve my design with your Suggestion. You open my mind so much. and I have one question to ask to you is "Can i solve problem by add comment number depend on article?" – Zabahey Jan 21 '11 at 08:34
  • I am not sure what you think, but bear in mind, class diagrams are for structure. – Gabriel Ščerbák Jan 21 '11 at 09:58
7

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.

Paws
  • 189
  • 2
  • 8