Re: [extremeprogramming] About placing configuration defaults
"Keith Nicholas" <[email protected]> Wed, 20 Nov 2019 10:41:05 +1300
| Newsgroups | gmane.comp.programming.extreme-programming |
|---|---|
| Message-ID | <CAC9mgDVuQVA1r2egp8q+9xPykUs8aq8SOE=2rHjJwhVBC1JaOg@mail.gmail.com> |
I quite like .NET Cores (and previous versions) approach to it It has a concept of configuration providers (command line arguments, environment variables, layered levels of configuration files, custom providers etc ) and enviroments like dev/testing/production that can all work to provide a final configuration given a certain context. It then has a concept of options which are derived from the assembled configuration. These options are designed to be dynamic so if you change a configuration in a file, it will by dynamically loaded into your running software. It also has validations on options, and lots of other toys. Options are then injectable into any of your classes. For an overview :- https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-3.0 https://docs.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-3.0 From a practical perspective, whatever your final store/s of configuration (lets say a config file ) it should have all the defaults defined. Implicit "in the code" defaults are invisible when systems are deployed and the software should fail fast if it doesn't have valid configuration. I am also a big fan of using logging to say what the options are and when they change. This also helps a lot depending on your deployment system. When software has to go to various different machines and be configured differently being able to see all the active options is very useful. While this seems complicated, the reality is it actually takes very little code / setup to do and is prettty easy to reason about. On Wed, Nov 20, 2019 at 3:28 AM Luiz Esmiralha <[email protected]> wrote: > Hello XP people, > > I am not sure if here is the right place to ask such a question, but I > know there are lots of people here that can program circles around me, so I > will give it a shot. If I am off-topic, well... sorry. :) > > Anyways, I've been thinking about configurations and defaults. And I would > like to know what are your thoughts on where to place defaults. Would you > centralize them all in one single place (such as a Configuration class at > the very edge of the system) or delegate each one to the components/classes > actually using it? > > My concrete case is (yet another) small test framework driven by a CLI. > There is some configs such as a folder to read the specs from, api keys, > URLs and so on. Some have sensible defaults, some don't. At the moment, the > configuration defaults are decided by the args parser and passed on to a > Configuration object that is used in every other place. > > What would you do instead? > > After writing it, the question seems so basic that it makes me blush a > bit. But that's me: always wondering if someone knows a better way of doing > what I do. > > Thanks a lot, > Esmiralha > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#160243): https://groups.io/g/extremeprogramming/message/160243 Mute This Topic: https://groups.io/mt/60557252/2417047 Group Owner: [email protected] Unsubscribe: https://groups.io/g/extremeprogramming/leave/4902963/619838065/xyzzy [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-