I know that this is going to sound like a real newbie question but it is one has been bugging me since I first started with Realbasic. I am a really long term user of Realbasic/Realstudio/Xojo and consider myself to be quite experienced in the environment and with OOP.
However, I really do not understand the difference between Protected and Private. I think I do understand the Private keyword but what on earth is Protected used for? I see it quite often in code snippets that I have downloaded over the years but can somebody (please) give me a simple to understand use case of where and why I would tag a property as Protected?
Thanks in advance.
These are the visibility modifiers of the method/property, which control from where in your code the method/property can be accessed.
Private visibility means that the method/property can only be accessed from within the class or module that actually contains it.
Protected visibility in classes means that the method/property can only be accessed from within the class or from within a subclass.
Protected visibility in a module means that the method property can be accessed from outside but only if using the fully qualified name (e.g.
mymodule.mymethod() rather than simply
Public visibility in a class means that anyone can access the method/property so long as they have a reference to an instance of the class.
In a module, public visibility means that the method/property can be accessed from anywhere in the code by name directly (AKA
Thanks to both @Andrew Lambert and @Eli Ott . I now understand!