Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33794
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: To deprecate or not |
| Date | 2016-02-13 11:02 -0500 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <n9nk26$tfo$2@gioia.aioe.org> (permalink) |
| References | <d0bb6e79-0125-4075-880a-5f4988370fee@googlegroups.com> <0708e041-47d3-41d9-8583-1f2a9be3bd6d@googlegroups.com> |
On 2/12/2016 8:59 AM, Eric Douglas wrote:
> On Friday, February 12, 2016 at 4:17:01 AM UTC-5, mike 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);
>>
>> As I see it we have two alternatives:
>>
>> 1.Add 'public String getValue(String arg1, String arg2);' in
>> InterfaceTop and @deprecate public String getValue(String arg1);
>>
>> A consequence of this will be that I need to replace methods in
>> implemetation. using InterfaceSub2. And handle a null or empty String
>> for arg2. But we still have a common interface.
>>
>> 2. Add 'public String getValue(String arg1, String arg2);' to InterfaceSub1.
>> I still need to implement both methods in implementation. Maybe
>> let
>> the "faulty" method throw UnsupportedOperationException.
>>
>> What is your view on this?
>
> That sounds like your easiest solution, if the second parameter is
> required and only for InterfaceSub1.
>
> public interface InterfaceSub1 extends InterfaceTop {
> public String getValue(String arg1) {
> throw new UnsupportedOperationException("second parameter required for this method on this interface");
> }
> public String getValue(String arg1,String arg2) {
> // new working code
> }
> }
The implementation code would need to be in the class implementing the
interface not the interface itself (unless Java 8 and marked as
default).
Arne
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next 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