External Configuration
by kirk knoernschild
Statement
Modules should be externally configurable.
Description
The ability to configure a module to it’s usage context increases our ability to reuse the module across contexts, whereas tightly coupling configuration to the module prohibits reuse. External configuration allows a module to be reconfigured across environemtns, and even within it’s existing environment, without demanding redeploying the module. Figure 1 illustrates External Configuration, where an XML configuration file is used by the Client class to configure the client.jar module.

Figure 1: External Configuration
Implementation Variations
Different configuration files can be used for different contexts. The configuration file can be included in the module or included in a separate module, depending on the flexibility desired. Figure 2 illustrates a configuration file that is not deployed with the module. A flexible alternative is to provide a default configuration file with the module, but allow for the module to be configured with an alternative configuration file. Including a default configuration file within the module is one aspect of providing a module’s Default Implementation.

Figure 2: External Configuration File
Consequences
Sample Code
Show example using Spring to configure a module with a uid/pwd combination.
For instance, many applications must provide credentials to connect to a database. Web applications often use a standard userid and password combination so that a pool of connections are available to clients. If a module encpasulates this information