Question

Say I have some data which I want several kinds of. I think the easiest example could be tiles in a game: I would have grass, rock, tree, etc. each with different sets of values.

I would immediately go ahead and make a file and read it in at runtime, so I wouldn't have to recompile it all for a tweak with something like C++. But if I was using Python, or some other intepreted language, would there be much point in having to make the file in a format like:

kind grass
colour 0xdfdfdf
walk true
see true

Rather than:

class grass(tile):
def init(self):
I can't remember how to init. parents
self.colour = 0xdfdfdf

The obvious benefit of the first is lost, when you don't compile.

Was it helpful?

Solution

Several other reasons, not least that a non-coder may change config, let's make them comfortable.

You may have many different config files for different situations. If you use your code-based approach you have true, syntactically more complex, code replicated for each different config instance. I'd claim that multiple copies of code is a bad thing.

Furthermore, config need not come from a file, it might (for example) be in a database - in distributed systems that may be better than a file. Hence separating code and config can give flexibility.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top