I have recently been reading The Pragmatic Programmer which states that:
Details mess up our pristine code—especially if they change frequently. Every time we have to go in and change the code to accommodate some change in business logic, or in the law, or in management's personal tastes of the day, we run the risk of breaking the system—of introducing a new bug.
Hunt, Andrew; Thomas, David (1999-10-20). The Pragmatic Programmer: From Journeyman to Master (Kindle Locations 2651-2653). Pearson Education (USA). Kindle Edition.
I am currently programming a web app that has some models that have properties that can only be from a set of values, e.g. (not actual example as the web app data confidential):
light->type = sphere / cube / cylinder
The light type can only be the above three values but according to TPP I should always code as if they could change and place their values in a config file. As there are several incidents of this throughout the app, my question is:
Should I store possibly values like these in:
- a config file:
'light-types' => array(sphere, cube, cylinder), 'other-type' => value, 'etc => etc-value
a single table in a database with one line for each config item
a database with a table for each config item (e.g. table: light_types; columns: id, name)
some other way?
Many thanks for any assistance / expertise offered.