2

I'm designing an online music website where there are two main objects: User and Music. There are many operations users can do to music,like they can upload,listen to, collect,share and download a music. If I draw an UML class diagram, the diagram would look like

this:

So my question is that is it OK with so many associations?

3
  • 1
    You should probably get a book and read some basics about UML. Your approach indicates that you did not understand them. Commented Apr 23, 2016 at 17:03
  • Welcome to StackOverflow, @Ivan. If you found an answer to your question, please consider accepting it (by clicking the check-mark), and consider up-voting it (by clicking the up arrow). Accepting an answer indicates to the wider community that you've found a solution, gives yourself some reputation points, and gives some reputation points to the person who answered your question. If you did not find a satisfactory answer to your question, please leave a comment. Commented May 13, 2016 at 2:34
  • @JimL. Sorry for later response. I have been too busy to check for what's updated here recently. Commented May 24, 2016 at 12:47

3 Answers 3

2

Those are not association, but methods which are to be defined in Music. You probably have just one association between both.

You might want to synthesize some use case cases first:

enter image description here

Based on this you can create a class model:

enter image description here

And detail this with behavioral design:

enter image description here

Sign up to request clarification or add additional context in comments.

8 Comments

I think you are right, but could you explain to me how to draw the class diagram in my case to make I understand the concept of class diagram better?
The problem is, that you are mixing quite a couple of things in your diagram. SO is not a tutorial place. So I recommend reading some books first to get the concept. When you stumble over details you are welcome to ask detailed questions.
Ok, I can come up with two detailed questions. First, if there is only one association between those two classes, how can I name it to summarize all methods given in my system schema?
Second, there may be different multiplicities for different methods. As to the method of user uploading music, the multiplicity on the end of the User class should be 1 as a certain music can only be uploaded by one user. But for another methods like user downloading music, that could be from zero to many as a certain music may not be downloaded by any user or may be download be one or more users. If I use only one association, how could the different multiplicities be separated?
I added a bit more explanation, but that's it. Please go and read a couple of books.
|
0

Having many associations between two classes is allowed by the UML standard. Strictly speaking, you should then add to each association role names to distinguish them when navigating from one class to the other.

5 Comments

I think the role names you mentioned is given in my diagram displayed above. If not, what's it exactly?
@Ivan: you are using association names. What Jordi is referring to used to be called "roles" in UML 1.x. Now they are called association-end properties. Each of these names is written at an end of the association line, near the corresponding multiplicity.
@Ivan: I just noticed your multiplicities are not written correctly. The min and max cardinalities of each multiplicity should not be separated. They should be written with ".." between the numbers, like 0..* for example. You may have entered some of the cardinalities as association-end names by mistake.
@JimL., I used visio 2013 to draw that diagram, just following the steps in this article to add multiplicities.
That article is incorrect in its modeling of multiplicities.
0

The model you have would be acceptable for a model of a problem domain. If this model is intended to be a model of the solution domain, you might have one association with operations representing available actions, or signals representing completed actions.

Since you use the class User, you are probably trying to model the solution domain, though. That suggests you should use operations or signals.

2 Comments

I don't quite understand the operations or signals you mentioned, could you explain it with more details please?
You could potentially use one association from User to Music. User can then invoke operations on Music. If you had interacting state machines in User and Music, or if the objects ran on separate machines, you could send signals instead. Music could have what are called signal receptions, which look almost the same as operations. (Although I just noticed that listenTo() and collect() operations don't make sense as operations or signals. You seem to have something in a netherworld between an analysis model and a design model.)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.