Bug 22771 - [refactoring] interface to abstract class (and vice versa)
Summary: [refactoring] interface to abstract class (and vice versa)
Status: ASSIGNED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: All All
: P4 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 35921 (view as bug list)
Depends on:
Blocks:
 
Reported: 2002-08-23 10:04 EDT by Ilja Preuss CLA
Modified: 2012-06-21 13:03 EDT (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ilja Preuss CLA 2002-08-23 10:04:33 EDT
It would be nice to have a refactoring to change an interface to an abstract 
class. That would include

- making up field declarations and method signatures (that is, adding "public 
final static" resp. "public abstract" where not already present)
- changing "implements" statements to "extends"
- and of course checking the preconditions for these actions

The reverse refactoring (purely abstract class to interface) would also be 
cool, of course.
Comment 1 Dirk Baeumer CLA 2002-08-23 10:15:38 EDT
Adam, what do you think about this for 2.x?
Comment 2 Adam Kiezun CLA 2002-08-23 10:23:00 EDT
i have never performed such an operation on my code so i'm having doubts 
about 'usefulness' of that refactoring. :)
i'd say: 'helpwanted'
Comment 3 Ilja Preuss CLA 2002-08-23 10:57:08 EDT
You never started with an interface and later discovered that you could benefit 
from the Template Method pattern? Exciting... ;-)
Comment 4 Adam Kiezun CLA 2002-08-23 11:12:54 EDT
now that i think about it, i guess i did - maybe once or twice in the last year.
might be just me, though. everybody works differently. :-) 
Comment 5 Adam Kiezun CLA 2002-08-23 11:15:46 EDT
sorry if i made it sound like i did not like the idea. 
the idea is good - it's a valid refactoring and people perform it on their code 
manually.
we just need to proritize feature requests.
Comment 6 Ilja Preuss CLA 2002-08-26 01:51:28 EDT
No problem. :-)

Regards, Ilja
Comment 7 Erich Gamma CLA 2002-08-28 06:23:10 EDT
"You never started with an interface and later discovered that you could 
benefit 
from the Template Method pattern? Exciting... ;-)"

Since you talk about patterns <g>
In this case I commonly use the Interface/Implementation Pair pattern:
InterfaceFoo
   AbstractFoo with template methods for interfaces.

The creation of an implementation pair is already supported by override methods.

Having said this, turning an interface into an abstract class can still make 
sense but given the above I consider it less important.
Comment 8 Ilja Preuss CLA 2002-08-28 06:39:07 EDT
I see your point... :-)

OTOH I often feel that the interface gets superfluous by the existence of the 
abstract class, so that getting rid of it would simplify the design.

Of course, I might sometimes later discover that meanwhile I need the 
interface, so that an "extract interface" refactoring would be handy... ;-) (I 
know there is an RFE for that, too.)
Comment 9 Benno Baumgartner CLA 2007-09-25 04:33:22 EDT
*** Bug 35921 has been marked as a duplicate of this bug. ***