2016-03-23 16:31 GMT-03:00 Peter Uhnák <i.uh...@gmail.com>:
>> I would do something like:
>>
>> Color named: #red.
>> Color named: #blue.
>
>
> That idea crossed my mind (it would be good for serialization from some
> external data), but how would you as user/programmer know what to put in
> there?
> The idea of enums is that you have a predetermined set of predetermined
> values, so this
>
>> Pros are that there is no endless lists of methods at class side
>
>
> is actually a con, because the user doesn't know them.
>
> Everyone knows red and blue, but nobody remembers to the letter
> domain-specific props (in fact half of the class-side colors you wouldn't
> guess you could use named).
>
> BormParticipantRole class selectors "#(#Approves #Undefined #Performs
> #Initiates #IsResponsible #Acquires #Cooperates #IsInformed #Consults)"
> BormParticipantType class selectors "#(#Organization #System #Person)"
>
> But maybe Color was wrong example because the set can be very large
> (although the set of options is also limited if you consider some
> standards).


You can have something at the class side that return the colors name,
using this example, by returning the keys of such dictionary.

Something like

YourClass class>>#colors

   ^Colors ifNil: [Colors := Dictionary new at: #red put: ...; at:
#blue put: ..; yourself]

Then you can have

YourClass class>>#colorsConstants
  ^self colors keys asSortedCollection

Regards

Esteban A. Maringolo

Reply via email to