Recently I started working on creating a client library. One problem which I am facing now is that I have to move the below interface Attributes to client library but the concrete classes (business logic) should remain in the original library. The problem here is that the method signatures of the below interface are Concrete classes.   public interface Attributes {      public Integer getAttribute(IntegerAttr attr);      public Boolean getAttribute(BooleanAttr attr);      public String getAttribute(StringAttr attr);      // some more code.  }Each of the above parameter classes implement one common interface called Attr. class IntegerAttr implements Attr { .. }class BooleanAttr implements Attr { .. }...Now if I try to make the parameters to type Attr in interface Attributes then we will get Override exception because of same method signature.But I have to move this interface to client library but not the concrete classes. Any suggestions on this please.
Moving interfaces but not concrete classes
object oriented;architecture;interfaces;class design;code reuse
Well, it would be easier to answer if you had told us what you are really trying to accomplish (for example, why you are going to move the interface), but anywhere.A straightforward approach works as follows:Create interfaces IIntegerAttr, IBooleanAttr and IStringAttr, all derived from Attr. Make IntegerAttr derive from IIntegerAttr (and the other two analogously). Change the signature of the getAttribute methods to use the new interfaces. Now you can move Attributes as well as the new interfaces to the client library, without having to move the concrete classes IntegerAttr, ....