Essentially what I have to know is:

I must show a drop lower listing of nations to my customers each country also offers a code connected into it. I will need to use both country and also the code What will be the ultimate way:

-We (the dev.) are planning on a table within our application database with this particular data, or XML file. -Our "architect" states that's old-fashioned which we ought to use constants within our application having a map that affiliates the nation using the code

Help me feel wise

To be sure along with you that you ought to easy code this or use constants. You will find a couple of good options based on yours needs:

  • Java Qualities Files - If you've just got a couple of key-value pairs to keep, fundamental essentials easiest way and simple to use.

  • XML Storage - If you're searching for persistence and therefore are searching at XML for storage, I would suggest searching at JAXB. It's a part of Java 6 and can build your existence simpler than attempting to make use of the DOM.

  • Database Persistence - For those who have more data that's altering frequently, you might take a look at storing it inside a database. JPA is a superb standard library for carrying this out. That's most likely overkill for what you're searching for though.

Final point here is hard coding is really a factor of history. You will find a whole lot methods for getting data in rapidly and simply without turning to hard coding everything.

Nations rarely change, so adding them statically as code or perhaps a config file appears reasonable. If you do not make use of a database for other things, don't add one for this purpose feature.

If you have XML parsing inside your application, make use of an XML file to define the information. It already solves a myriad of issues (for instance if you want to give a second attribute per country or something like that).

If you do not use XML for other things, I would recommend to try it out. It does not add much for your application. Otherwise, make use of a plain text file, perhaps a CSV one.

The various techniques have different advantages and disadvantages:

Database:

  • enables you to employ the nation data in queries
  • data could be transformed without redeploying the application
  • editing the information requires you to definitely write some kind of frontend or get it done by hand via some generic SQL browser
  • requires database access code, plus some kind of caching strategy
  • Any country-based logic within the code can break once the DB changes, or needs to be reflected within the DB

XML:

  • Super easy to edit
  • could be transformed without recompiling the application, but changes need to be used in some way
  • Requires parsing code plus some kind of caching strategy
  • Any country-based logic within the code can break once the XML changes, or needs to be reflected within the XML

Code:

  • Simple to edit - for designers
  • Changes require compilation and deployment
  • Requires no extra technical layers
  • Code and country data can't get free from synch

Overall, the "code as data" option would be indeed the best, when the compile&deploy step for every change is appropriate for you. Another solutions create overhead and duplication of structure (as well as logic) - with no, they do not like magic allow it to be "safe" to complete last-minute changes "since it is not code". Code is data, and information is code.

In a nutshell your architect is wrong (Or at best he's in case your paraphrase of his position is accurate). It should not maintain the code.

This information is not static a country's title changes, a replacement is founded, or some disappear.

So far as what mechanism, it does not always matter. Just make certain you are able to retrieve the information easily, you have unit tests, which there's straightforward mechanism to update the information.

I believe that "table solution" has more flexible approach: 1. You can handle data and hooking up qualities 2. You are able to use table directly 3. You may create connected map, according to db table))