Exactly the solution that I thought of :-)
On Mar 23, 2016, at 16:51, Esteban A. Maringolo <emaringolo@gmail.com> wrote:
2016-03-23 16:31 GMT-03:00 Peter Uhnák <i.uhnak@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
---> Save our in-boxes! http://emailcharter.org <--- Johan Fabry - http://pleiad.cl/~jfabry PLEIAD and RyCh labs - Computer Science Department (DCC) - University of Chile