1

I've taken the course Object Oriented System and Design at Stockholm University. I had to hand in an extra assignment where I had to create a UML Class Diagram reflecting a web site that sold cars (this is not a thread where I'm asking you to do my homework). This is what I handed in:

Description

The teacher said that "this isn't how you use attributes" and seems reluctant to explaining what I should have done differently. It's all in Swedish but I think that the main points are clear regardless of language.

My question is: How should this have been modeled differently? I have aggregation for some objects, enums because the website had a limited amount of attributes for some classes.

Any help is greatly appreciated.

Kind regards,

Hugo

user1185066
  • 11
  • 1
  • 3
  • Your image is completely unreadable. You should provide it with a decent resolution. – flyx Feb 02 '12 at 12:27
  • I'm sorry, I just updated it. It's not the full image but should be enough to go by (my teacher mainly brought up "Bil" and "Drivmedel"). – user1185066 Feb 02 '12 at 12:31

2 Answers2

1

I see some problems in your diagram:

  • I believe you have some enumerations in your diagram that are not defined properly. An enumeration should look like this.
  • You define attributes in addition to aggregation (e.g. the Bil has a aggregation relation to this SäkerhetsTilägg, and additionally defines an attribute säkerhet. You should either use a relation or an attribute, see here.
  • While we are at this, the multiplicities are somewhat confusing. You say that Bil can have any number of SäkerhetsTilägg, while the attribute säkerhet holds exactly one SäkerhetsTilägg.
  • Afaik, you have to define the visibility of attributes and methods (like +, - etc).
Community
  • 1
  • 1
flyx
  • 35,506
  • 7
  • 89
  • 126
  • Thanks for taking the time to look at it. I understand now that the enums are incorrectly implemented in this class diagram. I'm not really sure though why you should either use a relation or an attribute. Can I not have Drivmedel as a class and an attribute to Bil simultaneously? How is it written that the attribute säkerhet holds exactly one SäkerhetsTilägg? How would it be written if it could hold multiple? My teacher hasn't really expressed any concern for visibilty, though we did cover that in a seperate course. Thanks for your time. – user1185066 Feb 02 '12 at 13:03
  • You can define `Drivmedel` as a class and use it for an attribute type. But then, you should express the relation between `Drivmedel` and `Bil` as a dependency, not an aggregation (again, see the answer to the question I linked). As for the multiplicity, your `0..*` on `SäkarhetsTilägg` tells me that `Bil` can have any number of `SäkarhetsTilägg`. Just write `1` (or don't write any number). If you want express a multiplicity of may in an attribute, you couled use something like `SäkarhetsTilägg[1..n]` as type. However, this is specific to the programming language, while an aggregation is not. – flyx Feb 02 '12 at 13:10
  • Keep in mind that UML unless it is being used for generative purposes is just for communication. So the aggregation lines need not be the attributes as the diagram is just a view of the model. Additionally, the idea of a enumeration in UML is a bit vague, in that most people map it to a static/compiled thing like Java, does not change. This need not be the case, for example, one could argue that it should not be a enum but a class because each language could have a string etc. Just some more context. – Ted Johnson Feb 03 '12 at 04:32
0

It looks to me like you've got your Enumerations modeled as Classes. Even though visually an Enumeration looks like a Class with an <> stereotype, it's really a different thing altogether and it has EnumerationLiterals in the compartment when Attributes would be for a Class.

In ArgoUML you can create an Enumeration using the fourth button from the right on the toolbar. It's a dropdown menu which defaults to creating a new Datatype, but if you pull it down and select the green rectangle, it'll create an Enumeration. Create your Enumerations first and they'll be available for you to select as the type for your Attributes.

The final result should look like this: ArgoUML enumeration homework

Tom Morris
  • 10,490
  • 32
  • 53
  • Please read my answer above, where I say that, although they look visually similar, Enumeration isn't a stereotype. – Tom Morris Jan 23 '16 at 02:15