News for hackers. Stuff that matters.
Re:Ask HN: Why do you make class members private? by happytoexplain on Monday July 25, 2022 @02:22PM (#32228694)
>I'm only talking about code in the same project that everyone has access to. I'm not talking about defining an API for other people to use

Even within a single module of code, your public interfaces are "APIs". If I write a class that displays a paged interface in a popup modal, there is no relevant difference between a member of my team utilizing that class (from within the same module) and other people using it (as a library I have published). They both read the documenting comments and access the public members to achieve their goals, and both will suffer from the same confusion if there is no way to tell which members are the interface and which members are implementation details.

Re:Ask HN: Why do you make class members private? by robalni on Monday July 25, 2022 @04:44PM (#32230661)
> there is no relevant difference between a member of my team utilizing that class (from within the same module) and other people using it (as a library I have published).

The difference between a team member and a library user is that the team member works in the same project while library users have their own projects. So if you change something inside the class, you can change all the uses of that class in your project but you can't change other people's projects. That's why I added the clarification, because there is a very obvious reason to be strict about the API of a library that other people use: you can't change those uses.