Compatibility of Enum Vs. string constants
Posted
by
Yosi
on Programmers
See other posts from Programmers
or by Yosi
Published on 2013-11-06T13:35:31Z
Indexed on
2013/11/06
16:10 UTC
Read the original article
Hit count: 430
I was recently told that using Enum
:
public enum TaskEndState { Error, Completed, Running }
may have compatibility/serialization issues, and thus sometimes it's better to use const string:
public const string TASK_END_STATE = "END_STATE";
public const string TASK_END_STATE_ERROR = "TASK_END_STATE_ERROR";
public const string TASK_END_STATE_COMPLETE = "TASK_END_STATE_COMPLETE";
public const string TASK_END_STATE_RUNNING = "TASK_END_STATE_RUNNING";
Can you find practical use case where it may happen, is there any guidelines where Enum
's should be avoided?
Edit:
My production environment has multiple WFC services (different versions of the same product). A later version may/or may not include some new properties as Task end state (this is just an example). If we try to deserialize a new Enum
value in an older version of a specific service, it may not work.
© Programmers or respective owner