RE: how to: extract interface of class with methods from a superclass
"Donaldson, John" <[email protected]> Sat, 21 Sep 2013 09:11:04 +0000
| Newsgroups | gmane.comp.programming.refactoring |
|---|---|
| Message-ID | <716D07F3CBA94244A0922E7A99837C3A109FB7A4@G5W2715.americas.hpqcorp.net> |
Michal, Well, yes - any user of B sees A's methods. But when you "extract interface" you are doing to get the interface to that class - not its supertypes. You should extract the interface of A (IA, which will be implemented by A). Likewise B should implement the interface to B (IB). So, I can do that and implement two test classes TestA and TestB which implement IA and IB. And I can arrange that TestB inherits TestA. But my original class C imports interface IB (replacing B) - so I don't have the method on IA. It's not at clear how to refactor this without some really invasive modifications - which I'd like to avoid! So, the original question stands . what's the good way? John D. -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Michal Svoboda Sent: 20 September 2013 20:19 To: [email protected] Subject: Re: [refactoring] how to: extract interface of class with methods from a superclass Donaldson, John wrote: > Except, class B inherits class A and C is calling one of the inherited > methods. > > Quite rightly "extract interface" on B only gives me the methods on B. If B inherits A then interface of B should contain also interface of A. Perhaps only some autonomous extract interface tool doesn't see it? ------------------------------------ Yahoo! Groups Links