Overriding access to methods

The use of specific JADE features and proposals for new feature suggestions
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Overriding access to methods

Postby ConvertFromOldNGs » 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

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Overriding access to methods

Postby ConvertFromOldNGs » Fri Aug 07, 2009 10:51 am

by JensRichnow >> Mon, 15 Jul 2002 23:21:23 GMT

Yes, I would like to see such a feature where the signature of the overriden method can be changed to a different access modifier.

However, as far as I remember, the overriden method can be declared more public and not more private in Java. This is the opposite of what you are trying to achieve.

Designing the system to use top-level, possible abstract super classes (API design) would hide the imlementation of subclasses. However, this might not be possible in all cases.

If we talk overriding of methods what about overloading (which I find useful in Java)?


Return to “Feature Discussions”

Who is online

Users browsing this forum: No registered users and 10 guests

cron