views:

33

answers:

3

Hello.

I'm making an UML class diagram and I don't know how to do this:

I have a content that has a file. Both, content and file, are represented as classes. I've put an aggregation between content and file. But I don't know if is necessary to put an atribute inside content to represent file. Is necessary?

Thank you.

A: 

I think it may be confusing to represent the file as a class. It may be better to just put a note connected to the content explaining how the file ties in to your system. For example:

http://img100.imageshack.us/i/fileannotate.png/

If you put the attribute on the class diagram to represent it as a file I think there will be too much ambiguity in your diagram.

If the file is going to be used a lot then you may want to define the file as a sterotype in your UML diagram. For example if the file contained email addreses you may define the stereotype as (As long as the name means something in your problem domain):

<< EmailAddressStore >>

Having said that, depending on what your using the file for, the class diagram may not be the best place to represent it. It may be more appropriate to have the file in the deployment diagram. Like the log file in this example:

http://upload.wikimedia.org/wikipedia/en/d/da/UML_Deployment_Diagram.gif

David Relihan
+1  A: 

You can create associations in two ways:

  1. You can add a field inside the class
  2. You can connect two classes with association and add a name to it

So in your case you do not have a reason to add the field after you created an aggregation (which is a type of an association).

Gabriel Ščerbák
A: 

In an UML class diagramm the association (aggregation) already implies the link attribute. If you generate code from the diagramm and the link attribute is generated everything would be fine. Otherwise you need to include it yourself as a workaround.

stacker

related questions