I AM NOT A FRONTEND DEV !!! Check out my github

sydney.m.phillips0@gmail.com

Discord: @irevenant

I'm at an impass with my project

I have been mentally tormented by my project for the past few weeks, just developing and obsession with design choices, its been incredible.
What my current problem you may think, well its pretty straightforward, loading from files. Now this may seem kinda dumb, and it is, but I really am struggling to choose how to
handle loading from files.

Now currently, at 1.2.5, my program has a few different points where it will load in data from files to construct something. There is Console::createFont which came first, it seemed like a nice wrapper
for loading a font. But theres also Theme::Theme, ok honestly loading a file in a constructor feels like a bad practice to me, and it probably is, but
I didn't want to interfere with the struct too much, because that defeats the point of it being a struct tbh. There is also a third,
WidgetManager::loadWidgetsFromFile, kinda verbose but it works. Now all three of these do the same thing, they take a file name and load data from them.
They also avoid wrapper functions, which I like, Theme loads data only used by Theme, Console loads data only used by Console, etc, and they are called directly.

So thats all well and good but I mean, look at them. Three different patterns for loading files and they are all initialization time functions, awful, bad.
To give you an example heres some code,

	  
	  int32_t font = console.createFont("font.bmp", 8, 16);
	  ...
	  console.setTheme(conslr::Theme("theme.txt"));
	  ...
	  auto names = widgetManager.loadWidgetsFromFile("widgets.json");
	  
	  

It just doesnt look nice, and the past few days my brain has been at full processing power trying to find a way to unify them into some normal looking api.
Im Sydney, these are my problems, please message me suggestions.
-Sydney [palanoiska]

Edit 1

Well I collapsed it from 3 types of functions to 2, with createTheme and createFont in Console, and additionally having loadWidgetsFromFile,
I think this is much more bareable and will probably be handled by a seperate class eventually.
Thanks for those who read my struggles, I'll probably add better content soon -Sydney [palanoiska]

Home