extract interface

It would be nice if extract interface refactor gave you a way to tick
everything, or mark ranges with Shift-Click rather than having to tick
every method individually.

It might also be nice if it included default scope methods too, lumped
together. If you pick them, they would be extracted and converted to
public.

The "public" on methods implementing interfaces is not intended to
really be public if the interface itself is not public. That is a flaw
in the language design.


--
Roedy Green Canadian Mind Products
http://mindprod.com
If we have learned one thing from the history of invention and discovery, it is that, in the long run and often in the short one the most daring prophecies seem laughably conservative.
~ Arthur C. Clarke (born: 1917-12-16 died: 2008-03-19 at age: 90)

3 comments
Comment actions Permalink

On 1/23/2010 5:19 PM, Roedy Green wrote:

It would be nice if extract interface refactor gave you a way to tick
everything, or mark ranges with Shift-Click rather than having to tick
every method individually.

Umm, it does (at least on windows).  Select your ranges (Ctrl-A works
too for all), then press Space.
>

It might also be nice if it included default scope methods too, lumped
together. If you pick them, they would be extracted and converted to
public.

>

The "public" on methods implementing interfaces is not intended to
really be public if the interface itself is not public. That is a flaw
in the language design.

Which is a valid point, however you can design it so the implementation
was also not accessible publicly.  For situations like this, choose
composition over inheritance, even with interfaces.

0
Comment actions Permalink

On Sat, 23 Jan 2010 19:56:38 -0800, Daniel Pitts
<daniel@coloraura.com> wrote, quoted or indirectly quoted someone who
said :

>Which is a valid point, however you can design it so the implementation
>was also not accessible publicly.  For situations like this, choose
>composition over inheritance, even with interfaces

so the implementation has public methods, but the class itself is not
public, so the methods are not really exposed.

It is not obvious how you mechanically convert an interface with
several implementations to composition.

Any pearls to share?
--
Roedy Green Canadian Mind Products
http://mindprod.com
If we have learned one thing from the history of invention and discovery, it is that, in the long run and often in the short one the most daring prophecies seem laughably conservative.
~ Arthur C. Clarke (born: 1917-12-16 died: 2008-03-19 at age: 90)

0
Comment actions Permalink

On 1/24/2010 9:19 AM, Roedy Green wrote:

On Sat, 23 Jan 2010 19:56:38 -0800, Daniel Pitts
<daniel@coloraura.com>  wrote, quoted or indirectly quoted someone who
said :

>
>> Which is a valid point, however you can design it so the implementation
>> was also not accessible publicly.  For situations like this, choose
>> composition over inheritance, even with interfaces
>

so the implementation has public methods, but the class itself is not
public, so the methods are not really exposed.

>

It is not obvious how you mechanically convert an interface with
several implementations to composition.

>

Any pearls to share?


I have to use some handwork, but it could be made mechanical I think...

Create a inner class which implements the interface.  cut-n-paste the
existing implementation methods into that inner class.  Find all places
where objects of the given class are converted to the given interface,
and replace the usage to get an instance of the inner class...

There is at least one pitfal; if there is code that uses instanceof or a
cast, you have broken that code.

0

Please sign in to leave a comment.