Reputation: 961
I have a general programming question I’m sure you all have been confronted with at some point. I am working on an app for iPhone/iPad, although this isn’t really an iOS or Objective C question, that needs a few values for identifying and describing certain aspects of the application. For example, I might have shirts for sale as small, medium and large. Should these values just be enumerated in hard code inside of the application or is it better to put them into a database and use a relationship to the other database properties.
PS I’m not selling shirts.
Thanks in advance.
Upvotes: 2
Views: 1830
Reputation: 7275
From my experience I classify data into three areas:
If I think a value is going to never change (if it's an array, never have a value added), then I'm ok hard coding it.
If a value will need to be changed often - or I'd like to change it without recompiling - and it's a single value, then I'll put it in a config.
If the data has the potential to change a lot and grow (more and more values added), then I'll put it in a database.
Most of my decisions are driven by laziness. You need to think about the future and what will be the easiest thing to maintain.
As you said though, if the data is needed by other queries in your database, then put it in the database.
No matter what, make sure you have the data in one place. Don't put a value in a config file and the database.
Upvotes: 4
Reputation: 267
I guess putting them in database would be convenient since it will be easier for you to update the lists in the future.
Upvotes: 2