EC Notes: Section 4 section: A , all members should be Private of the
More simple to access
Users don't have to remember when to take parentheses, and when not to wear braces (because they're sure to have braces)
Access restrictions
For the member variables of public, we can arbitrarily set the value (whether legal or illegal, it will be unconditionally accepted)
But if we set it to private, then we can only expose the interface, we can not only control the access of the members (read-write, read-only, write-only, forbidden access), but also can check the incoming values, specify which values can be set, which is not.
Easier to maintain
We set the members to public, and if one day we find that this variable is not set up reasonably (it may be necessary to change its name or type), we must make modifications to each user code that uses this member variable.
And if we just expose the interface, we can modify it directly inside the tired, as long as the access interface remains the same.
EC notes: Part 4:22. All members should be private.