In a language like Python or JavaScript (NodeJS), is there anything wrong with d
ID: 646944 • Letter: I
Question
In a language like Python or JavaScript (NodeJS), is there anything wrong with defining "the configuration file" as a file which essentially hard-codes the configuration settings? For example:
options.py:
OUTPUT_DIRECTORY = 'out'
LOGLEVEL = 'debug'
options.js:
outputDirectory = 'out';
logLevel = 'debug';
Does this count as "hard-coding" options? When would it be inappropriate to expect a user to configure software this way? Is there any benefit to using a traditional configuration format (eg, ini file) which is parsed at run-time?
Explanation / Answer
I don't see anything wrong with that approach. It's very convenient in languages like Javascript, PHP, etc., and likely speeds things up by removing the need to parse & load configuration values.
Whether its the way to go is a different question. In software that is expected to be configured by a programmer - basically software where the 'end user' is a programmer, such as a CMS that gets installed onto a server, it'd work fine. In software that expects a non-technical end user to make configuration changes... probably not a good idea. For example, desktop apps written in Python.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.