[bug] Refactoring Sibling

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug] Refactoring Sibling

Tim M
I think the refactoring Convert to Sibling doesn't work as it should.

Given

  A
   +B
      -C
      -D

If you refactor sibling on B to introduce BParent I would expect

  A
  + BParent
       +B
           -C
           -D


Instead I get

  A
  + BParent
      - B
      - C
      - D


I know the warning says: enter a name for a superclass of B and its subclasses
but surely the result has taken that a bit too literally?

Tim


Reply | Threaded
Open this post in threaded view
|

Re: [bug] Refactoring Sibling

Bill Dargel
Tim M wrote:
> I think the refactoring Convert to Sibling doesn't work as it should.
>
> I know the warning says: enter a name for a superclass of B and its
> subclasses but surely the result has taken that a bit too literally?
>

I believe that's the way it's intended to work. It's described (briefly)
in http://st-www.cs.uiuc.edu/users/brant/Refactory/Old-Fixes.html when
it was added to the browser 9 years ago:
---
#  Added the children to sibling refactoring. Use this refactoring
whenever you have a non-abstract superclass that has several subclasses,
and you want to convert it to have an abstract class. For example, it
will convert
      A
           - B
           - C
to have the new abstract superclass, A':
      A'
           - A
           - B
           - C
Whenever this is run, it will push up the inherited methods and
variables, and write subclassResponsibility methods for those methods
defined in all subclasses.
---

The standard New... "Create Class" dialog can do what you ask for. For
example, to go from:
  A
   +B
      -C
      -D
to:
  A
  + BParent
       +B
           -C
           -D
Select A, do Class | New, make "BParent" the new class name, "A" will
have been set as the superclass (though changeable from the ...), and
then select "B" in the list of "Subclasses" (note that it's possible to
select multiple subclasses).

--
Bill Dargel            [hidden email]
Shoshana Technologies
100 West Joy Road, Ann Arbor, MI 48105  USA