Overriding access to methods
Posted: Fri Aug 07, 2009 10:51 am
by cdshearer >> Thu, 14 Mar 2002 20:44:07 GMT
Hi All
I'd be interested in opinions on this idea...
It would be nice if I could reimplement a public method on a subclass change its access to protected so that clients couldn't call the method. Other languages, such as Java have this feature.
There are quite a few methods in JADE which are public that really don't represent the public interface to the class. For example, the userNotification and sysNotification methods probably shouldn't be public. Another example is event methods on controls and forms.
There would obviously be issues such as polymorphic calls to an object's methods, but runtime exceptions could be raised for these.
I know that I can stop clients calling methods by reimplementing them and raising an exception when they are called, but changing their access would be a nicer option.
Craig
Hi All
I'd be interested in opinions on this idea...
It would be nice if I could reimplement a public method on a subclass change its access to protected so that clients couldn't call the method. Other languages, such as Java have this feature.
There are quite a few methods in JADE which are public that really don't represent the public interface to the class. For example, the userNotification and sysNotification methods probably shouldn't be public. Another example is event methods on controls and forms.
There would obviously be issues such as polymorphic calls to an object's methods, but runtime exceptions could be raised for these.
I know that I can stop clients calling methods by reimplementing them and raising an exception when they are called, but changing their access would be a nicer option.
Craig