Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33797
| From | Andreas Leitgeb <avl@logic.at> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: To deprecate or not |
| Date | 2016-02-15 00:53 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <slrnnc28h3.456.avl@login.logic.tuwien.ac.at> (permalink) |
| References | <d0bb6e79-0125-4075-880a-5f4988370fee@googlegroups.com> |
mike <mikaelpetterson@hotmail.com> wrote:
> I have an interface call it InterfaceTop that looks like this:
> public InterfaceTop {
> public String getValue(String arg1);
>
> }
> Then we have two sub interfaces call them InterfaceSub1 and InterfaceSub2.
> They both extend IntefaceTop.
> Now we discovered that the method in Inteface top produces erroneous output in
> in implementation of InterfaceSub1. We need an additional parameter to get value:
> public String getValue(String arg1, String arg2);
If ISub1 implementations need the 2-args method, and ISub2 implementations
don't need it, then the question is, whether ITop should even remain a
parent interface of ISub1 - or if the method should even remain in ITop
at all.
Interfaces are used to deal with a variety of implementations by a common
API. But if the variety of implementations doesn't agree on that common
API, then you should consider redesigning the interface hierarchy.
(and bumping the major version number, if it is in a non-private library.)
> Maybe let the "faulty" method throw UnsupportedOperationException.
Imho, that is a very bad idea. It's a way to defer errors to runtime that
could otherwise (with refined interfaces) be detectable at compile time.
PS: I know that the JSL uses a similar pattern for unmodifiable* classes,
but that's not quite the same, imho.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar | Unroll thread
To deprecate or not mike <mikaelpetterson@hotmail.com> - 2016-02-12 01:16 -0800
Re: To deprecate or not Eric Douglas <e.d.programmer@gmail.com> - 2016-02-12 05:59 -0800
Re: To deprecate or not Arne Vajhøj <arne@vajhoej.dk> - 2016-02-13 11:02 -0500
Re: To deprecate or not Eric Douglas <e.d.programmer@gmail.com> - 2016-02-15 05:12 -0800
Re: To deprecate or not Arne Vajhøj <arne@vajhoej.dk> - 2016-02-15 11:42 -0500
Re: To deprecate or not Arne Vajhøj <arne@vajhoej.dk> - 2016-02-13 11:34 -0500
Re: To deprecate or not Andreas Leitgeb <avl@logic.at> - 2016-02-15 00:53 +0000
csiph-web