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


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

Re: vocabulary

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: vocabulary
Date 2014-05-04 08:44 -0400
Organization A noiseless patient Spider
Message-ID <lk5cmr$qdg$1@dont-email.me> (permalink)
References <8l0pl95jubrn24j0tgnqcc21arhkii83ko@4ax.com><535caadc$0$6712$9b4e6d93@newsspool2.arcor-online.net><ljibu5$98l$1@speranza.aioe.org><535cda24$0$6715$9b4e6d93@newsspool2.arcor-online.net><ljilqs$vvv$1@speranza.aioe.org><f2nql9dvkidjochtle75491kv8fnkpnllr@4ax.com> <ljk0dh$cmn$1@dont-email.me> <qMGdnW2W7d7itvvOnZ2dnUVZ8kWdnZ2d@bt.com>

Show all headers | View raw


On 5/4/2014 8:00 AM, Chris Uppal wrote:
> Martin Gregorie wrote:
>
>> It seems to me that the only reason Java has both Abstract Class and
>> Interface definitions is to sidestep having to implement multiple
>> inheritance
>
> FWIW, I disagree with this entirely.
>
> For me, as for [some] others, interfaces are an expression of a /contract/  --
> they are used to communicate guarantees/requirements between producers and
> consumers of APIs.
>
> Abstract classes, on the other hand, are nothing to do with contractual
> communication between programmers.  They are skeleton implementations.
> [...]

     In what way does an abstract method declaration in an abstract class
differ from an abstract method declaration in an interface?  ISTM that
all abstract methods, wherever embedded, impose identical "contractual"
requirements on their concrete implementations.

     As for "skeleton implementations" ...

	abstract class Abstract {
	    abstract void setThing(Object obj);
	    abstract Object getThing();
	}

	interface Abstruse {
	    void setThing(Object obj);
	    Object getThing();
	}

There *is* a tiny skeletal shard to the former that the latter lacks:
Abstract has a constructor, while Abstruse does not.  But Abstract's
constructor is pretty minimal: A mere bone splinter, not a structural
element that can support weight and anchor muscles.  I think that if
you tried to argue that Abstract's trivial constructor amounted to an
"implementation," you'd get at best a grudging "Well, *technically*"
in response.

     By the way, one of the more intriguing (to me) uses of an abstract
class is to "un-implement" something:

	abstract class Disinheritor {
	    abstract String toString();
	}

A subclass of Disinheritor must provide its own toString() method, and
cannot simply inherit Object's.  So, does that make Disinheritor an
"anti-skeleton implementation" or a "skeleton anti-implementation?" ;-)

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

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


Thread

vocabulary Roedy Green <see_website@mindprod.com.invalid> - 2014-04-26 21:09 -0700
  Re: vocabulary markspace <markspace@nospam.nospam> - 2014-04-26 21:25 -0700
    Re: vocabulary "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-04-27 17:30 +1000
  Re: vocabulary Richard Maher <maher_rjSPAMLESS@hotmail.com> - 2014-04-27 14:42 +0800
  Re: vocabulary Marcel Müller <news.5.maazl@spamgourmet.org> - 2014-04-27 08:59 +0200
    Re: vocabulary "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-04-27 17:33 +1000
      Re: vocabulary Marcel Müller <news.5.maazl@spamgourmet.org> - 2014-04-27 12:21 +0200
        Re: vocabulary "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-04-27 20:23 +1000
          Re: vocabulary Roedy Green <see_website@mindprod.com.invalid> - 2014-04-27 12:52 -0700
            Re: vocabulary Martin Gregorie <martin@address-in-sig.invalid> - 2014-04-27 22:30 +0000
              Re: vocabulary Marcel Müller <news.5.maazl@spamgourmet.org> - 2014-04-28 08:23 +0200
              Re: vocabulary "Chris Uppal" <chris.uppal@metagnostic.REMOVE-THIS.org> - 2014-05-04 13:00 +0100
                Re: vocabulary Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-05-04 08:44 -0400
  Re: vocabulary lipska the kat <lipskathekat@example.com> - 2014-04-27 09:01 +0100
    Re: vocabulary "Qu0ll" <Qu0llSixFour@gmail.com> - 2014-04-27 19:53 +1000
      Re: vocabulary lipska the kat <lipskathekat@example.com> - 2014-04-27 11:43 +0100
  Re: vocabulary Jeff Higgins <jeff@invalid.invalid> - 2014-04-27 07:14 -0400
  Re: vocabulary Jeff Higgins <jeff@invalid.invalid> - 2014-04-27 07:32 -0400

csiph-web