Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: @Override Date: Mon, 23 Jul 2012 22:16:05 -0400 Organization: A noiseless patient Spider Lines: 45 Message-ID: References: <75036e8b-8b5f-4ea4-aef7-c063249f5707@googlegroups.com> <500de50a$0$289$14726298@news.sunsite.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Tue, 24 Jul 2012 02:16:13 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="d3779b2c4a3397eb5709eec94bad057a"; logging-data="13984"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/2ZyQTSwGmrsj6N9sNH+jG" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 In-Reply-To: <500de50a$0$289$14726298@news.sunsite.dk> Cancel-Lock: sha1:zu/Dfsi59mOTvX2h2agtDaasMq0= Xref: csiph.com comp.lang.java.programmer:16288 On 7/23/2012 7:58 PM, Arne Vajhøj wrote: > On 7/23/2012 4:35 PM, Eric Sosman wrote: >> On 7/23/2012 2:30 PM, bob smith wrote: >>> Is it really necessary to write @Override when you override or is this >>> just "a good thing"? >> >> Two benefits of @Override appear to me, one from its presence >> and one from its absence: >> >> - If you write @Override and then misspell the method name or >> mess up the parameter list, Java will say "Hey, wait: There's >> nothing in the superclass with this signature; what do you >> think you're doing?" And then you'll say "Oops!" and fix >> the problem, instead of wondering why your "overriding" method >> doesn't seem to work. >> >> - If you write a method and your IDE starts suggesting that you >> ought to tag it with @Override, you'll be alerted that you've >> overridden something you didn't intend to.[*] >> >> Two benefits; that's all I see. Hence, like indentation and >> Javadoc comments, not "really necessary" ... > > I see the biggest benefits being the documentation. > > It can be important to know that ones method may be called > by the super class. > > And all arguments seems related to extends not implements, so > I m not convinced that extending it to interface methods was > wise. A separate @Implements annotation instead of @Override might have been better for interfaces. But what should one do about abstract methods in abstract superclasses? Are those @Override or @Implements, or maybe @Concretizes? And why should the class with the actual implementation care about the distinction? And what about concrete methods *intended* to be overridden, as in MouseAdapter? @ProFormaOverrides? Looks like fodder for a "whichness of the why" debate. -- Eric Sosman esosman@ieee-dot-org.invalid