0

Using the code below as an example

public abstract class Foo<T,V>{
   // ...some methods

   public interface IFoo<S,U>{
      S doSomething(U input);
    }   

}

    class MyClass implements Foo.IFoo<String, Integer>{}

Is calling the interface like that bad OOP or there is nothing wrong with that. Note the interface has different generic parameters from the abstract class.

Tendai
  • 71
  • 6
  • 1
    The fact that the interface is public either implies intended usage or bad design. So it depends on the actual use case. – root Jun 07 '20 at 22:32
  • Can you please give /describe the use-case where this would be a bad design? – Tendai Jun 10 '20 at 02:44
  • 1
    bad design: e.g. if `IFoo` is supposed to be used only within `Foo`, but was declared public instead. Or if `IFoo` is something that needs to be its own file (e.g. `FileReader`), but was for some reason coupled with `Foo`. Or if `IFoo` is intended for inherited classes but is not `protected`. – root Jun 10 '20 at 03:14
  • 1
    intended usage example: `IFoo` is part of `Foo`'s API. – root Jun 10 '20 at 03:16
  • I see. That really helps Thanks. – Tendai Jun 10 '20 at 20:06

0 Answers0