✅ When should/shouldn't I split off code into a separate lib project?
I am cleaning up a massive legacy codebase at work. At the time my company acquired it, it consisted of 71 projects (spread across 6 solutions, which we have already merged into 1 for easier dependency management). 11 Of these are executables, the rest are libs. Some of these libs are definitely unnecessary (e.g. only containing 1 class that barely even warrants its own namespace), others are definitely necessary (e.g. needed by multiple executables). Likewise, there is a huge "common" project that is referenced everywhere because it contains all sorts of things, and dependants usually only need a small subset, so it seems reasonable to split it up to reduce coupling.
So far we have brought it down to 1 solution with 31 projects, but I'm reaching a point where I'm no longer confident in making these decisions solely by gut feeling, and I'd much prefer having some clear principles to follow, because I've come to realize that splitting based on what's-needed-where can be done with endless granularity, and I don't know where to draw the line.
1. What are some general rules of thumb to follow?
2. How does project splitting affect
* IDE performance
* compile time
* binary size
* runtime performance?
3. Is an executable depending on another executable (as opposed to extracting a shared lib project) even a fundamentally bad thing?
8 Replies
Unknown User•14h ago
Message Not Public
Sign In & Join Server To View
glad to have that reaffirmed. but out of curiosity, can you elaborate on why/how? like, why do you say
you can't do that
when at the same time it will technically work
?
I have noticed that only projects with changes get re-compiled, does the compiler do something similar on a per-namespace (per perhaps even per-file) basis?
i'm glad you bring that up, its been bugging me ever since i started working hereUnknown User•14h ago
Message Not Public
Sign In & Join Server To View
rather than start immediately worrying about
- IDE performance
- compile time
- binary size
- runtime performance
i would first analyze the designing part
if a project/library is isolated it means it is a dependency, so it has a version, so it is to maintain in all these aspect, which could be a good thing or a bad thing
it depends how many libraries there are, how many people will maintain it, and so on, so i would complete a general study on that and then take decisions
ok forget my predictions, i really just meant to ask: does project splitting change what is and isn't recompiled? (idk how much compilers can reuse from previous builds)
Unknown User•13h ago
Message Not Public
Sign In & Join Server To View
I recommend slngen
and making new solution files as necessary
also if your projects share configuration, and they probably do, use target files
and Directory.build.targets/props
Unknown User•13h ago
Message Not Public
Sign In & Join Server To View