String dbUsername = "myuser"June 24, 2023 | Development
hope you're doing well today.
For this one, I got a little quick "tip" for you, which I read again from the book "The Pragmatic Programmer".
The title of this blog post gives you a bit of a hint but it's about supplying your specific application data via metadata files. This can be plain text, JSON, XML, or whatever files.
But why should you put in the extra work of configuring such a system? I mean, this needs a lot of extra stuff, which in most cases you don't necessarily need, like file reading, parsing, handling of the contents, and so on.
Well, there are quite a few reasons for that. Let me elaborate.
- First, it forces you to design your program in a more generalized, robust, and decoupled way. If your core can handle various, sometimes even "unknown" outcomes, you will have something more flexible, adaptable, and robust, in the end.
- This then allows you to implement customizations much more easily than without. You could argue that these metadata files are a way of those customizations by themselves and serve as a basis for other possible changes.
- This metadata isn't also by itself something that should be inside your program logic anyways. Think about it. Every time you need to make a change to those details, you need to completely recompile your program. That shouldn't be the case. Also, imagine pushing your database login data as part of your source code into a public repository. I don't have to tell you that this is a pretty big security risk.
- Also, metadata can be expressed in a way that is much more understandable and closer to your actual problem domain.
So yeah. I think those were more than enough reasons for that argument and for you to put in that extra bit of work. You also don't have to put in the complete amount of work every time. Most of the time a generic library might even do the trick.
What are you waiting for then?