Is this OOP approach doomed to fail or is there some merit in this?
Before I understood abstract classes I was getting more or less the same benefits of code reuse by using an interface class + a regular class that implements certain methods of the interface. For example
public interface IMyService
{
String Helloword1();
String Helloword2();
String Helloword3();
}
public class MyService
{
public String Helloword1(){return "1";}
public String Helloword2(){return "2";}
//Helloworld3 is not here so I would be forced to provide implementation in any subclass
//very similar to calling abstract on a method
}
public class SubClass1: MyService, IMyService
{
public String Helloword3(){return "3";}
}
public class SubClass2: MyService, IMyService
{
public new String Helloword2(){return "override method";}
public String Helloword3(){return "3";}
}
Can anyone see of any advantage of doing this or is this really providing the same advantages as an abstract class?
SubClass2.Helloword2()hidesMyService.Helloword2(), it does not override it.