开发者

UML aggregation. Is necessary to put an atributte? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
开发者_如何学编程

Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.

Closed 5 years ago.

Improve this question

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.


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).


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜