abcfantasy
Programmer
Say there is an xml file (or maybe other kinds of file) that contain general settings about your application (can be anything: text/integers/etc...).
Now, you have a method which gets the settings from the file and returns them as one object, what should the object be? Assume that the types of the settings vary.
1. Should it be a kind of array that holds objects? In this case, you need to hardcode a lot of things. For each setting, you will have to specify in which place the setting is in the array, and type cast it to the correct type. So if any of these two changes, you would need to change more code. Also, would it be better to use ArrayList or simply object[]?
2. Should it be a whole new class simply to store the settings in seperate fields?
3. Perhaps any other option?
I've encountered this several times. The first seems the easiest, shortest and quickest to do but somehow there's a "dirty" feeling in doing that. The second seems good, but feels like too much work involved for a simple thing.
So I was wondering what is considered to be "good practice" to tackle such a situation.
Thanks in advance.
|| ABC
Now, you have a method which gets the settings from the file and returns them as one object, what should the object be? Assume that the types of the settings vary.
1. Should it be a kind of array that holds objects? In this case, you need to hardcode a lot of things. For each setting, you will have to specify in which place the setting is in the array, and type cast it to the correct type. So if any of these two changes, you would need to change more code. Also, would it be better to use ArrayList or simply object[]?
2. Should it be a whole new class simply to store the settings in seperate fields?
3. Perhaps any other option?
I've encountered this several times. The first seems the easiest, shortest and quickest to do but somehow there's a "dirty" feeling in doing that. The second seems good, but feels like too much work involved for a simple thing.
So I was wondering what is considered to be "good practice" to tackle such a situation.
Thanks in advance.
|| ABC