Hi!
I have a situation that may seem ridiculus but I have not been able to figure out a good enough solution. To simplify things the problem is something like this, suppose you have an object like Manufacturer that has a countryname property (like car.Manufacturer.CountryName) and you want to be sure that the countryname property can not have duplicates or misspellings or other errors.
It is basically a string property but a string can be anything which I do not want. An object seems like overkill and an enum means I have to recompile if new countries are to be added or existing countries to be changed.
I could easily control this in a GUI but I need to control this in the application code. So I have an object with a property that could be a string, an object or an enum (or other) and I cant decide which to use. So my options are something like this:
a) Control this in the GUI and do not check this in the application code, taking the risk that I can get "illegal" country names.
b) Make an object (Country) and use that, which is overkill and makes the code more complex, but I have complete control over duplicates and all that stuff.
c) Use an enum and hope that I do not have to recompile too often. It is simple and effective but a static solution.
d) Use an internal string list of valid country names and have CountryName as a string property and make sure that it is validated against that string. I get validation and CountryName is just a simple string, but what if I change that internal string of valid country names? Than I have to make code the revalidates all Manufacturer objects in the program too make sure they still have valid contry names.
I am not totally sure how important it is too have valid country names but the more I think about this the more I realize that I am in a grey zone. An object, or struct, is too much, an enum too static, a string too simple.
I could be totally overcomplicating things here but I would really like too know what to do, or rather how to think, when you get into this grey zone of object vs string vs enum.
Thankfully yours! Hal