@badnetmask Great question!
I typically like to relocate code to an internal library where that code becomes interesting and topical rather than boring. If that’s not the best choice, I might put it in a different module. Really what I’m trying to do is go from “I wrote this for internally relevant reasons” to “here’s how we solve this specific issue in this context given this motivation”
As an example, one could imagine writing a weird hacky inverse square root function that happens to work pretty well. Sure, you could just stick it in the code and comment “wtf?” (Like the historical implementation did: https://en.wikipedia.org/wiki/Fast_inverse_square_root). After all it’s “just” a quirky performance optimization of a common function. But how am I going to find that code and know what to do with it when/if hardware advances make it obsolete in the future? And how do I explain why we even did this?
If it’s just buried somewhere in a codebase, it’s hard to find. Doubly so if it’s “boring” code. It’d probably end up in a random utils file if we didn’t just inline it in the few places it’s used in… But if it’s in a library that implements hardware optimized mathematical functions? Now it’s interesting and relevant *and* I can much better understand when to evolve the code in the future.