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


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

Re: java inheritance

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: java inheritance
Date 2013-11-11 09:12 -0500
Organization A noiseless patient Spider
Message-ID <l5qokq$d7j$1@dont-email.me> (permalink)
References <88bf3eb6-4f5a-4745-9bea-fcc4bdaba816@googlegroups.com>

Show all headers | View raw


On 11/11/2013 8:30 AM, asdf9797 wrote:
> Hi
>
> I did a java test recently and one of the questions was on the subject of
> inheritance/ OO design
>
> The idea was there was a "Storable" abstract class which contained a store() method.
>
> There was a IStorable interface
>
> And then there was
>
> class Book extends Storable implements IStorable {
>     public void save(Book) {
>     }
>
> }
> The question was how to improve the implementation.

     Fixing the syntax error would be a good start ...

> What is the current thinking on extending abstract classes ?

     The current thinking is that an abstract class that's not
extended is very nearly useless.  ;-)

> Is that the issue?

     I don't know what the test-setters were looking for.  Perhaps
the Storable class already implements IStorable, so the "implements"
part in Book is redundant.  Maybe they felt the abstract class didn't
add value, and hoped you would discard "extends Storable".  It's
possible they wanted the save() method to take any Storable (or
maybe IStorable) instead of insisting on a Book.  Possibly all they
wanted was a trivial renaming, something along the lines of

	interface Storable { ... }
	abstract class AbstractStorable implements Storable { ... }
	class Book extends AbstractStorable { ... }

     Some design schemes are fairly rigid about such things -- make
an interface with THIS kind of name, and an abstract implementing
class with THAT kind of name, and so on and so on.  If the testers
were aficionados of one such scheme, perhaps they were just trying to
find out whether you, too, were familiar with it.  I'd say familiarity
with a particular set of conventions is not quite the same thing as
familiarity with Java and/or with O-O design -- but maybe that's not
what they were after.

-- 
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

java inheritance asdf9797 <paul.caffrey@gmail.com> - 2013-11-11 05:30 -0800
  Re: java inheritance Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-11-11 09:12 -0500
  Re: java inheritance Arne Vajhøj <arne@vajhoej.dk> - 2013-11-11 09:40 -0500
  Re: java inheritance markspace <markspace@nospam.nospam> - 2013-11-11 09:45 -0800
    Re: java inheritance Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-11-18 09:24 -0400
  Re: java inheritance Robert Klemme <shortcutter@googlemail.com> - 2013-11-11 19:19 +0100

csiph-web