If you put these functions only into separate files because of their size, you could also just add member functions that forward to the global ones which are declared in the other files. It’s a bit more work, but it gives you a clean interface and all functions are declared in one place:
By the way you’ll actually see this pattern commonly when it comes to handling OS-specific code, since now you could switch out the implementation based on your requirements, e.g.
I’m also interested in the design aspect, especially when the game grows and more and more features are implemented which might affect the lemming. I’m working with C++ codebases which have multiple god types where a lot of features of the whole game are imported/included into one file/type because of this. This leads to large rebuilds for small changes and slow compile times.
I always thought a better way might be to put some logic into other files which take the Lemming. So that only the features, which require the logic, import this file and it does not clutter all other features which depend on the Lemming itself (although a Lemmings game would probably not reach the scope of this).
I’m not sure how compile-time/rebuilds are impacted in Zig which has no header files and if this should also be taken into account for such a design.
in my experience I’ve never noticed a difference, maybe there is but if there is one it’s probably too small to measure. In C++ it’s really slow though I sympathize with you, such a horrid compiler, I used to work on a codebase where each compile would take 6 min which already felt unbearable, I can’t imagine people who needed multiple hours/days to compiler programs before.
Back in the day I worked on a system where a full debug rebuild on a beefy dev desktop took a week. Luckily you never really needed to do that, and building just your component was 20 min.
Having it compile on your own machine was way better than handing a 2ft stack of punch cards to an intern at the window and picking up your printout the next morning: “Syntax error on line 1237”
oh my god, we have it so good nowadays, can’t imagine the pain of working on something for days, compiling it, and a week later getting hit by the syntax error, no wonder so much software engineer, became landscaper, or farmer ahah
Once upon a time, I worked in the development department of an ERP system whose core was written in C++. The build process took 5 hours. The build started at 00:00, and at 05:00, deployment to all test servers was launched; after that, automated tests were started. By the time I got to work at 09:00, the automated test reports were already available, and a new cycle would begin.
.. submitting tiny patches to a Jenkins CI queue that took an hour or more to reach your job. CI runs with tests that took minimum 45 minutes, with a 40% chance of failing due to flakes .. which means resubmit the job back on the queue .. which infers you need to be vigilant for the whole process, or miss the window if it fails. If that means missing lunch, then yeah, miss lunch.
Sometimes you were 45 minutes away from a green build, sometimes several days. If it was days, you were guaranteed to have new merge conflicts by then.
Basically getting paid to sit there and watch paint dry.
That’s not quite right. Each developer tested the functionality they were working on on their own computer with the environment set up, and that was quite fast. But the entire product was very large, and its full build, including all the changes made by all the developers, took 5 hours.
This doesn’t mean that the developer had to wait that long to test each change. But it did take that much time to check the entire product with all the changes that had been made.