I have an interface say A with method1(). There is 1 abstract class say B which implements this interface A. The abstract class has implemented the method1 with 2 more methods, methodE, methodD. If I want to add 1more methodH which will do methodE, MethodD and another new one methodZ, what can I do in this case? Should I make a new method in interface or abstract class?
Consider what will happen when you upcast. That is, if you instantiate an object that extends the abstract class, and then upcast its reference to the interface type, would it make sense for the new method to be available there?
"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer sscce.org
Joined: Jan 29, 2003
If you put it on your interface then all implementations of the interface will have to implement it, not just the abstract class you have today.
If you put it on your abstract class then any references that are typed to the interface cannot call it. Does that matter?
Avoid this really ugly situation:
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi