Skip to content
This repository has been archived by the owner on Apr 6, 2021. It is now read-only.

Handling of enums #5

Open
danhaywood opened this issue Jul 13, 2012 · 0 comments
Open

Handling of enums #5

danhaywood opened this issue Jul 13, 2012 · 0 comments
Milestone

Comments

@danhaywood
Copy link
Contributor

ver: 1.0.0
raisedby: stefcascarini

ref: http://restfulobjects.codeplex.com/workitem/30

Two solutions (within the current spec) come to mind

  1. the value in all ways is presented and set as a string.
  2. Present the value as the correct underlying integral type with the choices as the set of possible integral underlying values.

I'm not keen on 1.

  • It doesn't fit with the existing model from MVC where we use the underlying type and the enum 'name' is just a presentation hint for the UI.
  • It's possible (certainly in .net) for an enum to have an integral value that doesn't map to a string representation.
  • If we have a more sophisticated way of supporting enums in a later spec this is not backwards compatible.
  • Concealing the underlying type like this 'feels' wrong and will create lots of nasty special cases in the code.

However 2. for the moment means that enums don't really add any value (just the set of possible values).

I would propose to do 2. now but ask for some explicit support in the next version of the spec.

eg how about something in the extensions (and formal types) which contains 'display hints' and a map
(eg {{"Male : 0}, {"Female" : 1}}) which would allow a client to display the value and choices in a friendly way but
send and receive the underlying type.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant