user1185066
user1185066

Reputation: 11

Confusion about how attributes work in UML Class Diagrams

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

Upvotes: 1

Views: 5075

Answers (2)

Tom Morris
Tom Morris

Reputation: 10540

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

Upvotes: 0

flyx
flyx

Reputation: 39708

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

Upvotes: 1

Related Questions