Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 490
TonE Avatar asked May 28 '26 05:05

TonE


1 Answers

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.

like image 176
Richard Avatar answered May 30 '26 19:05

Richard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!