Book a Demo

Author Topic: This is probably a dumb question ...  (Read 4122 times)

ianw

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
This is probably a dumb question ...
« on: February 07, 2006, 11:35:44 am »
... but what is the recommended way of defining and using a enumeration as an attribute type in a class diagram?

Eg Class1 has an attribute Attrib1, that should be an enumerated type.

I have tried created a 2nd class, Enum1, stereotyped as an enumeration, and then used it as the type of Attrib1. This does the job but

a) seems a trifle long-winded, and
b) how do I specify the enumeration values?

Is there better way?

I apologise in advance if this is dealt with somewhere, but I couldn't find it.

Ian

Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: This is probably a dumb question ...
« Reply #1 on: February 07, 2006, 11:37:36 am »
Hi Ian,

just enter the enumeration values as attributes of the <<enumeration>> stereotyped class.

Hope this helps!
Bruno

Quote
... but what is the recommended way of defining and using a enumeration as an attribute type in a class diagram?

Eg Class1 has an attribute Attrib1, that should be an enumerated type.

I have tried created a 2nd class, Enum1, stereotyped as an enumeration, and then used it as the type of Attrib1. This does the job but

a) seems a trifle long-winded, and
b) how do I specify the enumeration values?

Is there better way?

I apologise in advance if this is dealt with somewhere, but I couldn't find it.

Ian


ianw

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: This is probably a dumb question ...
« Reply #2 on: February 07, 2006, 11:50:42 am »
Hi Bruno,

Thanks for that - I take I am doing it the 'right' way then?

Cheers
Ian

Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: This is probably a dumb question ...
« Reply #3 on: February 07, 2006, 12:27:04 pm »
Hi Ian,

you certainly are!

Bruno

Quote
Hi Bruno,

Thanks for that - I take I am doing it the 'right' way then?

Cheers
Ian


Scott Lindner

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
    • View Profile
Re: This is probably a dumb question ...
« Reply #4 on: April 28, 2006, 03:06:53 pm »
I want to do the same thing but I have to admit... I'm still missing something after reading this short thread.

I have a class that defines an enumareted type.  I created a new attribute for each enumerated value, I specified the type of each enumerated value to be an "int" and then gave a value to each attributes.

In another class I used this enumerated class as a type for one of the attributes.  I wanted to set the initial value for this attribute, and I have to manually type the value.  With how tied in everything is in EA, this doesn't make me feel like I'm doing it correctly.  I'd expect to be able to select from the set of enumerated values in the enumerated class.

Did I do something wrong?

Scott

Bruno.Cossi

  • EA User
  • **
  • Posts: 803
  • Karma: +0/-0
    • View Profile
Re: This is probably a dumb question ...
« Reply #5 on: April 28, 2006, 04:17:52 pm »
Hi Scott,

You are on the right track. I am afraid that even with the enumeration, EA won't offer you a dropdown listbox with the values to choose from, you do have to manually enter the default one yourself.

Bruno

Quote
I want to do the same thing but I have to admit... I'm still missing something after reading this short thread.

I have a class that defines an enumareted type.  I created a new attribute for each enumerated value, I specified the type of each enumerated value to be an "int" and then gave a value to each attributes.

In another class I used this enumerated class as a type for one of the attributes.  I wanted to set the initial value for this attribute, and I have to manually type the value.  With how tied in everything is in EA, this doesn't make me feel like I'm doing it correctly.  I'd expect to be able to select from the set of enumerated values in the enumerated class.

Did I do something wrong?

Scott


«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: This is probably a dumb question ...
« Reply #6 on: April 28, 2006, 04:31:06 pm »
Also, for generation purposes you (seem to) have to know what the underlying data type is. That's not always true for some paradigms (although the language may make the choice for you at build time).

EA does its best, but cannot always tie the 'outermost' class, the attribute, the enumeration, and the enumeration's attributes' underlying data types (where defined) together.

That said: EA does a pretty fair job, and few other products can handle the above gracefully.

Perhaps this whole enumeration subject is another area where we can propose enhancements to Sparx.
No, you can't have it!