Re: The Override Problem
- From: "Robert Klemme" <bob.news@xxxxxxx>
- Date: Mon, 11 Jul 2005 09:52:40 +0200
Tom N wrote:
> Roedy Green wrote:
>
>> I am about the describe one of the most frustrating features of Java
>> -- the total lack of safety nets when it comes to overriding methods.
>> Tracking these down take me days.
>>
>> Any hints on techniques for ensuring the error never happens are
>> welcome or for finding them when suspected.
>>
>> I love abstract methods. The compiler dutifully checked that I
>> remembered to implement every last one, to spell it perfectly and to
>> get the signature bang on.
>>
>> But sometimes I want to provide a default implementation that I
>> occasionally override.
>>
>> I tend to screw up and make a teensy spelling error in the name, or
>> get the method signature off by a hair. The compiler gives me no
>> warning at all. Basically my new methods is totally ignored and that
>> class uses the default implementation.
>
> JBuilder provides an "override method" wizard which can insert stubs
> for all inherited abstract methods and can insert stubs for selected
> inherited concrete methods. There is also a wizard to implement an
> interface.
I was going to say the same: use a decent IDE.
> Presumably some other tools will do something similar.
Yes, eclipse has similar tools: you can select the methods you want to
override and get appropriate stubs.
> That solves the problem when initially writing the subclass but it
> doesn't handle the case where you either later change the signature
> of the parent class abstract method or accidentally change the
> subclass by editing.
No problem with eclipse if you use the refactoring "rename": all methods
in sub classes are changed similarly.
Kind regards
robert
.
- References:
- The Override Problem
- From: Roedy Green
- Re: The Override Problem
- From: Tom N
- The Override Problem
- Prev by Date: Re: The Override Problem
- Next by Date: Re: New Applet Restriction?
- Previous by thread: Re: The Override Problem
- Next by thread: Re: The Override Problem
- Index(es):
Relevant Pages
|