Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's the terminology?
Message
From
16/06/2010 13:26:12
Timothy Bryan
Sharpline Consultants
Conroe, Texas, United States
 
 
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
C# 3.0
Miscellaneous
Thread ID:
01469189
Message ID:
01469274
Views:
23
Viv,

I agree completely. I was suggesting if there was a table that had values for status and the user could add those or change them at will and a enum was built based on those values, you couldn't code against that. The two would have to be two seperate pieces. The purpose of enums is to nail down values and get away from having fuzzy strings. As it turned out, that wasn't what Frank was trying to do so it all is well. Enums are a great fit for what he is trying to do. Coding logic against enums is great. Coding logic against unknown values the user enters isn't so great.

Tim

>>Hard coding something that could have potential for update or change is probably not the best way to do it.
>
>Not sure I agree. The dangers are proably less when using enums than with other options.
>
>>I would put something like that in a table so they can be updated. What if all of a sudden somebody needed a status of "Canceled" on those?
>
>Simply add it on to the *end* of the enum. But. if the enumeration is likely to change I always specify a value for each item. e.g:
 enum Status : byte
>    {
>        Pending = 1,
>        InForce = 2,
>        Deferred = 3,
>        Matured = 4
>    }
>
>That, combined with a little discipline, is as foolproof as any other method? Adding an additional value is not going to affect the legitimacy of an existing data store.
>
>>Enumerations are great for inside your code when you have code choices that are fixed. Like mmSaveDataResult.RulesPassed or mmSaveDataResult.RulesBroken. Those are enumerations you are already using. They are defined with the enum keyword.
>>
>>public enum mmSaveDataResult
>>{
>>     RulesPassed,
>>     RulesBroken,
>>     etc
>>}
>>
>>Tim
>>
>>>>>Hi,
>>>>>
>>>>>my mind has gone blank this morning trying to remember the name of the coding structure that lets you define constants and let your code use them like a pick list.
>>>>>
>>>>>For example, I want to define a list like this:
>>>>>
>>>>>1 - Pending
>>>>>2 - In Force
>>>>>3 - Deferred
>>>>>4 - Matured
>>>>>and so on.
>>>>>
>>>>>Then when I refer to this structure while writing my code it is easy to see which number corresponds to which term.
>>>>>
>>>>>What I am looking for is an easy way to define the current status of an item and make it easy for this status to be translated to other languages. Is this the best way to achieve this?
>>>>
>>>>Enumerations.
>>>
>>>Thanks Mike!
>>>
>>>Do you think this is the best way to achieve this? Or can you suggest alternatives? Maybe I should just use a table with values so that they can be translated if needed?
Timothy Bryan
Previous
Reply
Map
View

Click here to load this message in the networking platform