I have a situation that may seem ridiculous, but I could not find a good enough solution. To simplify the situation, the problem is this: suppose you have an object such as a Manufacturer with the countryname property (for example, car.Manufacturer.CountryName), and you want to be sure that the countryname property cannot have duplicates or spelling errors or other errors.
This is basically a property of the string, but the string may be what I don't want. The object seems redundant, and the listing means that I have to recompile if new countries are added or existing countries are changed.
I could easily control this in the GUI, but I need to manage this in the application code. Thus, I have an object with a property, which can be a string, an object or an enumeration (or another), and I cannot decide what to use. So my options look something like this:
a) Control it in the graphical interface and do not check it in the application code, risking getting "illegal" country names.
b) Create an object (Country) and use it, which is redundant and makes the code more complex, but I have full control over duplicates and all that.
c) Use the enumeration and hope that I do not have to recompile too often. This is a simple and effective, but static solution.
d) Use the internal string list of valid country names and assign CountryName as a string property and make sure it is checked for this string. I get confirmation, and CountryName is a simple string, but what if I change this internal string of valid country names? What should I do the code, it checks all the manufacturer objects in the program, also make sure that they still have valid account assignment names.
I'm not quite sure how important it is for him to have the correct country names, but the more I think about it, the more I understand that I'm in the gray zone. The object or structure is too much, the enumeration is too static, the string is too simple.
I could completely exaggerate here, but I would really like to know what to do, or rather, how to think when you get into this gray area of the object vs string vs enum.
, !
Hal