When do you decide to introduce classes vs keep free functions in C++?
I’ve noticed a pattern in a lot of C++ codebases where things start out very function-oriented and straightforward, but as soon as the system grows, there’s a strong pull toward introducing classes even when the original logic doesn’t obviously need state.
At the same time, I’ve also seen the opposite problem where people avoid classes entirely and end up with large, tightly connected sets of free functions that become harder to reason about as shared data starts creeping in.
I’m trying to understand how experienced C++ developers actually decide that boundary in practice. Is it usually driven by ownership and state modeling first, or is it more about managing complexity as it appears over time?
https://redd.it/1t8b6h2
@r_cpp
Post #25161
21