2 ms·
Some decades ago as a child I read a Bjarne Stroustrup interview where he said you use those things to enforce invariants and if you don’t you keep access simpl
by renewiltord 2y ago
Some decades ago as a child I read a Bjarne Stroustrup interview where he said you use those things to enforce invariants and if you don’t you keep access simple. In the intervening decades, I’ve found that when I have a new invariant I often need to confirm the call sites are compliant anyway as he says. So I just use that, keeping accessors only where required or where interface compliance syntactically requires it.
https://www.artima.com/articles/the-c-style-sweet-spot https://www.artima.com/articles/the-c-style-sweet-spot