No this is better OOP than what you can do with public and private alone.
Lets say you have a method that ONLY other classes in the same package can access. You can now limit the access to what is required using internal. This is much better than making it public to everything.
This works the same with protected. If you subclass a class and you need to access it methods in your subclasses you can mark the method protected. This limits the access to subclasses only. Without it, you again would have to make it public. Therefore you can now be stricter, which is better.
Quote:
|
i should use -protected- only if i intend to make some subclass override some method of my class
|
That is incorrect. You use protected for any method or variable that you want to access from a subclass.
override is used when you want to alter a method that is inherited from you superclass. It must return tha same type and take exactly the same parameters as the original method.
You may also be interested in 'final'. specifying a method as final means that it cannot be overriden. so if you had a superclass with a method you want to be able to access from a subclass, but you don't want your subclass to be able to override it, you specify the original method as final.
Code:
// This cannot be overriden, but can be accessed by subclasses.
protected final function methodName():void
{
// Actions here.
}