3 ms·
`private` is a joke in C++. Coupling happens at the header file level, not the class level. Any C++ programmer who cares about reducing dependencies should be
by blt 12y ago
`private` is a joke in C++. Coupling happens at the header file level, not the class level. Any C++ programmer who cares about reducing dependencies should be thinking about header files, not classes.
Man, we really need a module system.
I think the problem is not that `private` exists, but that it is taught/sold to programmers as a silver bullet for making software architectures better. People think "Decoupled systems are good. `private` hides my variables from the outside world. Therefore, if I use `private` variables, my system will be decoupled." This is false. A program can use `private` extensively and still be tightly coupled.
So, I agree with the author that `private` encourages myopic engineering, but I think education is a better way to fix the problem than removing the features.
- quanticle 12y ago>Man, we really need a module system. And you might be getting one: https://isocpp.org/files/papers/n4214.pdf https://isocpp.org/files/papers/n4214.pdf It's under consideration for C++17, as I recall. EDIT: Also, CLANG allows you to use modules right now, but IIRC those are CLANG specific extensions and the final module spec. may or may not be compatible with them.
- JoeAltmaier 12y agoPerhaps 'private' is oversold. It can be used simply to isolate variable changes. So you don't have to grep the entire source for references. So you can make changes confidently. Yes there can be some leakage; but don't throw the baby out with the bath water.