Understanding Program Configuration

In this lesson, we'll clearly define what program configuration is and distinguish code from configuration, which is not always easy.

The basic idea of configuration is that the user should be able to choose how the program behaves without having to modify the code. We will explore the many facets of configuration such as command-line flags, environment variables, configuration and files.

Code, input, configuration and configuration as code

Most non-trivial programs have input, which they process. The input can vary, but a program typically processes the input in the same way. Discounting programs that by design introduce random elements, running the same code on the same input should produce the same output. Many programs can also be configured to operate in different ways, so the same input will produce different outputs depending on the configuration. For example, the echo command prints a newline by default. If you execute two consecutive echo commands their output will be displayed on two separate lines. Try it:

Get hands-on with 1400+ tech skills courses.