This is not a literal coding question, I’m just wondering, what’s the point of using public and private functions and variables? Where would I use each of them?
I’ve always thought of them as being “old” or not needed anymore, but I’m sure there’s a good reason they’re used in some places.
Basically, when you are developing a class that other developers will use :
publicmethods and variables are what the other developers will (need to) use — what your class doesprivatemethods and variables are what you, as the developer of that class, used to make it work — it’s how your class works internally.Others need to be able to use your class ; but not to know how it does it.
If you want to know more, you’ll have to search for Encapsulation.