3 ms·
We did this with a project I worked on. I came on after the code was mature. While we didn't have 2000 globals, we did have a non-trivial amount, spread over a
by magicalhippo 3y ago
We did this with a project I worked on. I came on after the code was mature.
While we didn't have 2000 globals, we did have a non-trivial amount, spread over about 300kLOC of C++.
We started by just stuffing them into a "context" struct, and every function that accessed a global thus needed to take a context instance as a new parameter. This was tedious but easy.
However the upside was that this highlighted poor architecture. Over time we refactored those bits and the main context struct shrunk significantly.
The result was better and more modular code, and overall well worth the effort in our case, in my opinion.