4
Brosyl
15d

I'm creating a little "cloud" app, for training and learning about how network communications work. I try to do it with SOLID principles in mind, but it's faster said than done, as I don't have a lot of experience.
Anyway, I want to write the server config in a file which would be read at launch, but I'm wondering how you'd do it while respecting SOLID as much as possible.
Do you see any interesting design pattern I could dive into to implement this part while still being able to change or add things efficiently ?
Or any open source project where I could read the code and inspire myself for my project ?

For example, things I might want to implement later (and reasons to make the code flexible) :
- At first the config file is read only (edited manually) but later you'd be able to update it from within the app
- Later in development, you could maybe use overwriting flags when launching the server from command line
- Currently, if a field in the config file is invalid or absent, an error is displayed and the program closes. I intend to use default values instead, or to ask the user to manually enter the parameters before continuing execution
- I'd like to be able to switch the file format without changing much code (currently in JSON, because parsing libraries are easy to use, but it could switch to YAML or XML or whatever)
- Maybe even switch to a config stored in database instead of a simple file ?
- To be portable, the config path depends on the OS (AppData for Windows, $HOME/.config/ for Linux, $HOME/Library/Preferences for OSX...) but could be also given from the command line

It's a training personal project and a challenge, not something which is intended to be released publicly (in its current state), so I don't really care about YAGNI or "using a database is a dumb idea", I'm just trying to force myself to apply SOLID principles in front or real potential problems (not tuto code).

Also note that I'm asking for advice, not that you do all the work for me, of course. If you have a design pattern or two that come in mind, or an open-source project which already reads config from a file from which I could inspire myself, just cite a name, I'll do the research myself (I'm already, actually, but some guidance would be helpful).

Comments
Your Job Suck?
Get a Better Job
Add Comment