I see that many attributes are written as private or protected. What is the purpose of this?
I read online that it says to prevent others from modifying it at will, but I don’t understand who the other person is referring to? Are they colleagues in the company?
So if you develop the program by yourself, do you not need to set up privatization? If it is public, it will be simple to write and convenient to call?
For example, when developing a WeChat official account, if there is an APPID in it, you should write a private attribute to store it instead of a public one, so that when others call your method, this value cannot be changed
Private method means that external calls are not allowed. It usually performs an operation inside the class. If it is called directly using a class instance, an error will be reported. If it is defined as private, the method will not be visible in some IDE editors.