Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #16270

Re: @Override

From Lew <lewbloch@gmail.com>
Newsgroups comp.lang.java.programmer
Subject Re: @Override
Date 2012-07-23 14:51 -0700
Organization http://groups.google.com
Message-ID <3efdf82b-e94f-4608-82a7-0132b52b8977@googlegroups.com> (permalink)
References <75036e8b-8b5f-4ea4-aef7-c063249f5707@googlegroups.com> <jukcik$t0m$1@dont-email.me> <9da89e66-d7df-47e1-84d4-2dddea7d744f@googlegroups.com> <jukgd7$k7n$1@dont-email.me>

Show all headers | View raw


On Monday, July 23, 2012 2:40:21 PM UTC-7, Daniele Futtorovic wrote:
> On 23/07/2012 22:59, Lew allegedly wrote:
> &gt; Eric Sosman wrote:
> &gt;&gt; bob smith wrote:
> &gt;&gt;&gt; Is it really necessary to write @Override when you override or is this just &quot;a good thing&quot;?
> &gt;&gt;
> &gt;&gt;      Two benefits of @Override appear to me, one from its presence
> &gt;&gt; and one from its absence:
> &gt;&gt;
> &gt;&gt;      - If you write @Override and then misspell the method name or
> &gt;&gt;        mess up the parameter list, Java will say &quot;Hey, wait: There&#39;s
> &gt;&gt;        nothing in the superclass with this signature; what do you
> &gt;&gt;        think you&#39;re doing?&quot;  And then you&#39;ll say &quot;Oops!&quot; and fix
> &gt;&gt;        the problem, instead of wondering why your &quot;overriding&quot; method
> &gt;&gt;        doesn&#39;t seem to work.
> &gt;&gt;
> &gt;&gt;      - If you write a method and your IDE starts suggesting that you
> &gt;&gt;        ought to tag it with @Override, you&#39;ll be alerted that you&#39;ve
> &gt;&gt;        overridden something you didn&#39;t intend to.[*]
> &gt;&gt;
> &gt;&gt;      Two benefits; that&#39;s all I see.  Hence, like indentation and
> &gt; 
> &gt; And that wasn&#39;t enough?
> &gt; 
> &gt; Add the third benefit that I mentioned upthread. Aren&#39;t they enough now?
> &gt; 
> &gt; Is your disparaging tone rhetorical, or do you really find the 
> &gt; benefit of &#39;@Override&#39; to be that marginal?
> &gt; 
> &gt; Because it isn&#39;t.
> &gt; 
> &gt;&gt; Javadoc comments, not &quot;really necessary&quot; ...
> &gt; 
> &gt; Dental patient:
> &gt;   Is flossing my teeth really necessary? Which ones do 
> &gt;   *really* need to floss?
> &gt; 
> &gt; Dentist:
> &gt;   Just the ones you want to keep!
> &gt; 
> &gt;&gt;      [*] This actually happened to me earlier today.  I was writing
> &gt;&gt; a little Swing doodad to edit the &quot;locations&quot; of inventory items,
> &gt;&gt; and I gave it a getLocation() method.  NetBeans started clamoring
> &gt;&gt; for @Override, and I realized that my doodad extended JPanel which
> &gt;&gt; in turn extended JComponent, which already has a getLocation() ...
> &gt;&gt; Time for &quot;Facepalm!&quot; and a quick name change.
> &gt; 
> &gt; That is an excellent anecdote to support the idea that the 
> &gt; &#39;@Override&#39; annotation is really necessary.
> &gt; 
> &gt; But only where you want to catch bugs at compile time before 
> &gt; they bite you in production.
> &gt; 
> 
> Uh... there was a (pretty long) time when people and programs *did*
> manage to exist without that annotation, you know. No need to be overly
> dramatic.

You sound like Grandpaw complaining that kids these days have it too easy.
"In my day, we had to check for ourselves whether the method overrode a 
parent method!"

Your irrelevant observation does not give a reason to eschew '@Override'.

The fact is that Java *does* have it, and it *is* useful for the class of bugs 
it helps prevent. 

A point you ignore in your rush to fallacious argumentation.

That languages (including Java itself) didn't used to have 
it is hardly an argument against it. In fact, that Java added it, given the 
language's resistance to change, is strong evidence in favor of it. 
So your evidence supports use of '@Override'. You drew exactly the 
opposite of the correct conclusion from your data.

-- 
Lew

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

@Override bob smith <bob@coolfone.comze.com> - 2012-07-23 11:30 -0700
  Re: @Override Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-23 20:52 +0200
  Re: @Override markspace <-@.> - 2012-07-23 11:54 -0700
    Re: @Override Lew <lewbloch@gmail.com> - 2012-07-23 13:05 -0700
    Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-23 19:54 -0400
  Re: @Override "John B. Matthews" <nospam@nospam.invalid> - 2012-07-23 15:56 -0400
    Re: @Override Peter Duniho <NpOeStPeAdM@NnOwSlPiAnMk.com> - 2012-07-23 14:19 -0700
      Re: @Override rossum <rossum48@coldmail.com> - 2012-07-24 13:09 +0100
        Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-24 21:29 -0400
      Re: @Override Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-24 09:04 -0400
  Re: @Override Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-23 16:35 -0400
    Re: @Override Lew <lewbloch@gmail.com> - 2012-07-23 13:59 -0700
      Re: @Override Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-23 23:40 +0200
        Re: @Override Lew <lewbloch@gmail.com> - 2012-07-23 14:51 -0700
          Re: @Override Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2012-07-24 00:08 +0200
            Re: @Override Lew <lewbloch@gmail.com> - 2012-07-23 16:57 -0700
      Re: @Override Robert Klemme <shortcutter@googlemail.com> - 2012-07-24 09:46 +0200
    Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-23 19:58 -0400
      Re: @Override Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-23 22:16 -0400
        Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-23 22:57 -0400
          Re: @Override Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-07-23 23:47 -0400
            Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-24 21:35 -0400
    Re: @Override Jim Janney <jjanney@shell.xmission.com> - 2012-07-26 20:00 -0600
  Re: @Override Gene Wirchenko <genew@ocis.net> - 2012-07-23 14:01 -0700
  Re: @Override Silvio Bierman <silvio@moc.com> - 2012-07-24 00:22 +0200
    Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-23 19:53 -0400
      Re: @Override Gene Wirchenko <genew@ocis.net> - 2012-07-23 18:59 -0700
      Re: @Override Silvio Bierman <silvio@moc.com> - 2012-07-24 22:57 +0200
        Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-24 21:24 -0400
    Re: @Override Robert Klemme <shortcutter@googlemail.com> - 2012-07-24 15:36 +0200
      Re: @Override Gene Wirchenko <genew@ocis.net> - 2012-07-24 09:54 -0700
      Re: @Override Silvio Bierman <silvio@moc.com> - 2012-07-24 23:14 +0200
        Re: @Override Robert Klemme <shortcutter@googlemail.com> - 2012-07-25 07:57 +0200
          Re: @Override Gene Wirchenko <genew@ocis.net> - 2012-07-25 10:34 -0700
          Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-25 14:54 -0400
            Re: @Override Wanja Gayk <brixomatic@yahoo.com> - 2012-07-30 14:42 +0200
      Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-24 21:20 -0400
        Re: @Override Lew <noone@lewscanon.com> - 2012-07-25 06:26 -0700
          Re: @Override Arne Vajhøj <arne@vajhoej.dk> - 2012-07-25 17:16 -0400
  Re: @Override Roedy Green <see_website@mindprod.com.invalid> - 2012-07-23 20:59 -0700
  Re: @Override Wanja Gayk <brixomatic@yahoo.com> - 2012-07-24 16:06 +0200

csiph-web