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


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

Re: Object orientation question

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Object orientation question
Date Mon, 27 Oct 2014 16:51:19 -0400
Organization A noiseless patient Spider
Lines 63
Message-ID <m2mb82$cef$1@dont-email.me> (permalink)
References <0b94f856-9631-48ee-8d2d-94055d79cfd6@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Mon, 27 Oct 2014 20:51:15 +0000 (UTC)
Injection-Info mx02.eternal-september.org; posting-host="bd4e1cba8d8592bec5d5ed9e4537fbfd"; logging-data="12751"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/ZNTEEudC2tJFES4my107m"
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0
In-Reply-To <0b94f856-9631-48ee-8d2d-94055d79cfd6@googlegroups.com>
Cancel-Lock sha1:7KJdt6Kz0gtvbIBPKzPoott9O8w=
Xref csiph.com comp.lang.java.programmer:30215

Show key headers only | View raw


On 10/27/2014 4:26 PM, mike wrote:
> Hi,
>
> Let me take an example.
>
> We have an interface called BaseIface and then we have a BaseImpl. Then we have AddtionInterface and AdditionImpl. AdditionInterface is a BaseInterface.
>
>
>
> Now if we have the following:
>
> public class AdditionImpl implements AdditionInterface, BaseInterface {
>
>
> }
>
> or
>
> public interface AdditionInterface extends BaseInterface {
>
> }
>
> And then have
>
> public class AdditionImpl implements AdditionInterface {
>
>
> }
>
> I think the first option is more clear. Since when I look at the class I can see that it has a AdditionInterface and a BaseInterface. Then I know what the class is.
>
> I would like to hear if this approach is correct or how do you view it?

     Clearly, the generated code is the same: AdditionInterface extends
BaseInterface, therefore any class implementing AdditionInterface also
necessarily implements BaseInterface.  If the class fails to provide a
method specified by BaseInterface, the code won't compile.  So the
question is purely about readability and style.

     Unless there's something rather unusual going on, I'd tend to favor
brevity: Just say `class AdditionImpl implements AdditionInterface' and
let it go at that.  Anyone who's curious about exactly what classes are
extended and which interfaces are implemented can always consult the
Javadoc, where it's all spelled out in gory detail.

     Let me pose a counter-question: What would you think of

	public class AdditionImpl extends JFrame
	    implements AdditionInterface
	{ ... }

versus

	public class AdditionImpl extends JFrame
	    implements AdditionInterface, BaseInterface,
	    ImageObserver, MenuContainer, Serializable,
	    Accessible, RootPaneContainer, WindowConstants
	{ ... }

?  Is readability improved by the extra detail?

-- 
esosman@comcast-dot-net.invalid

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


Thread

Object orientation question mike <mikaelpetterson@hotmail.com> - 2014-10-27 13:26 -0700
  Re: Object orientation question Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-10-27 16:51 -0400
    Re: Object orientation question Robert Klemme <shortcutter@googlemail.com> - 2014-10-27 23:51 +0100
      Re: Object orientation question Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-10-28 09:45 +0000
        Re: Object orientation question Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-10-28 08:29 -0400
          Re: Object orientation question Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-10-28 08:33 -0400
            Re: Object orientation question Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-10-28 16:26 +0000
        Re: Object orientation question Robert Klemme <shortcutter@googlemail.com> - 2014-10-29 08:35 +0100
          Re: Object orientation question Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-10-30 00:32 +0000

csiph-web