Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What's the terminology?
Message
De
16/06/2010 12:47:59
 
 
À
16/06/2010 12:24:54
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
Information générale
Forum:
ASP.NET
Catégorie:
Code, syntaxe and commandes
Versions des environnements
Environment:
C# 3.0
Divers
Thread ID:
01469189
Message ID:
01469262
Vues:
39
Tim,

I think you may not be understanding fully what I am trying to do. Or maybe I am not understanding the point you are trying to make. So, I'll try to explain the full story.

The system is an Insurance Administration system. Insurance Policies can move through various statuses. Initially it is tagged as "Pending", then it can go to either "In Force", "Withdrawn" or "Deferred". From "In Force" it can go to "Lapsed", "Matured", etc. I am controlling what status gets set in my code.

As I don't want to force my status names on the end user (for example they may want "In Force" to actually be "Issued"), what I am doing is using a code in the background that the end user never sees, so "Pending" = 1, "In Force" = 2, and so on. So I created a Status table with the code and the Status Name/Description. The user will only ever see/edit the name (but they must understand that if they change "In Force" to "Matured" then things will look a little strange!)

Now, in my code, rather than wanting to have to remember which status code corresponds with the "Withdrawn" status, I set up an enum which will return the correct code for me.

I *think* this makes sense. :)

>The purpose of enums is to provide a coding consistency and expose the options to components. Just like the example I gave you with mmSaveDataResult, how would you know what you could program to in code if Kevin had used a bunch of strings? Even if you created your enumeration based on what was in a table, how would you use that in code to make decisions? While it is possible to create a switch statement based on enums, how could you effectively code against unknown values?
>
>mmSaveDataResult only matters to the code and it is a situation where the programmer knew what he needed and how to use those variables. When you introduce values the user needs to enter and use and have meaning to, then it makes sense to make put them in a table. If you create enums that match and you program off of this, you should probably not let the users change those values or your code could be in jeoprady.
>
>Just stuff to think about it.
>Tim
>
>>>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform