Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What's the terminology?
Message
From
16/06/2010 12:15:15
 
 
To
16/06/2010 11:02:25
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:
01469247
Views:
37
>Hard coding something that could have potential for update or change is probably not the best way to do it. 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?
>

Well, my goal is to make my coding a bit easier, but also allow for translation of what the end user will see in their interface. So what I have done is put all the various statuses in a table and I have a form that allows the user to edit the status, but not the statuscode, which is what my code will use for its business logic. I also created an enum which mirrors the values in the table, so my coding is easier and I don't have to remember the different possible values. If I need to add in a new status, then I will have to remember to add the value to the table as well as to my enum, but I'm willing to live with that.

What would be ideal would be if I could get the enum to automatically get built from the table, which is what Mike seems to do with nHibernate.

>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?
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform