简体   繁体   中英

Enum for ISO3166 countries - acceptable practice?

I'm developing an ASP.NET MVC 3 application and it uses a complex model which is serialized/deserialized to/from XML.

Some fields require ISO3166 country codes. I have several defined Enums for other restricted lists (which are very unlikely to change) which are marked with the XmlEnum attribute and displayed neatly using DisplyFor/EditorFor templates.

In order to be consistent I created an Enum of the ISO3166 country codes.

However I am aware these will change overtime requiring me to re-build/deploy the project.

Given the frequency/likelyhood of the ISO3166 codes changing, is this acceptable practice?

Enumerations are conceptually a related collection of constants, ie. they do not change —a client assembly can make this assumption and directly compile in the value of the enum field.

But ISO 3166 does change, often several times a year . For example the creation of the new country South Sudan will need to be reflected in an update.

Isn't this just configuration data? I would XML serialize a List<MyCountryCodeClass> of the country codes and place this in a CountryCodes.xml file in the App_Data folder.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM