Creating a top-level main() function
In Chapter 13, Configuration Files and Persistence, we suggested two application configuration design patterns:
The global property map: In the previous examples, we implemented the global property map with a
Namespace
object created byArgumentParser
.Object construction: The idea behind object construction was to build the required object instances from the configuration parameters, effectively demoting the global property map to a local property map inside the
main()
function and not saving the properties.
What we showed you in the previous section was the use of a local Namespace
object to collect all of the parameters. From this, we can build the necessary application objects that will do the real work of the application. The two design patterns aren't a dichotomy; they're complementary. We used Namespace
to accumulate a consistent set of values and then built the various objects based on the values in that namespace.
This leads us to a design for...