I have a Java app with three classes:
Baz. All three depend on a bunch of what are currently constants defined in each class in order to determine how to run. On top of that,
Baz interacts with a number of builder classes that need to be set up in various ways.
I'd like to refactor out all of the configuration info in to a .properties file so that I don't have to recompile every time I change a constant.
But I'm not sure how to structure it:
Do I have a
ConfigInfoSingleton that holds all of the parameters of the application in static properties, and have other classes ask it for information when they need it? That seems wrong, as it introduces global state.
Do I pass around a
ConfigInfoMap as a parameter to all of the classes that need that info? Then I need to have
Baz parsing strings in order to decide what they're going to do, and that seems very wrong. Especially in the case of
Baz, where I can't just pass around values, but I need to use
switch statements on configuration info to determine builder method calls.
Do I parse the info in a different class, and have that class tell the others how to set themselves up? Then I have a class that needs to know about everyone else's implementation details, which seems wrong, but less so than the other options.
This seems like a really basic question but I'm not sure how to proceed in terms of good software design, and I haven't had much luck Googling. Whats the "right" thing to do?