Discussion:
Large refactorings
Johan Lindstrom
2003-05-03 16:12:10 UTC
Permalink
What is a large refactoring, and when is it too large?

What's the largest refactoring you made work? What's the smallest one that
didn't work out so well? What did you do then?


/J
-------- ------ ---- --- -- -- -- - - - - -
Johan Lindström Sourcerer @ Boss Casinos ***@bahnhof.se

Latest bookmark: "Domino Changes with Static Typing by David Buck..."
http://www.whysmalltalk.com/articles/buck/domino.htm
dmoz (1 of 8): /Computers/Programming/Languages/Bistro/ 31



To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Phlip
2003-05-03 16:31:56 UTC
Permalink
Post by Johan Lindstrom
What is a large refactoring, and when is it too large?
In pure XP, any large refactoring is a process smell. It indicates the team
repressed many small easy refactorings. Such a team should vow to refactor
more during each user story. Maybe just that vow will nibble away at the
large design smell, a little during each task.

However, this ideal assumes greenfield XP and other mythical beasts. Facts
on the ground, some refactors take months. One does them a tiny bit at a
time.

http://www.c2.com/cgi/wiki?RefactorLowHangingFruit
Post by Johan Lindstrom
What's the largest refactoring you made work?
I refactored the world's stinkiest BASIC code into (in my humble opinion)
adequate Ruby code.

http://flea.sf.net

Yes, refactor. One little edit at a time. Did it with this technique:

http://www.c2.com/cgi/wiki?ExtractAlgorithmRefactor
Post by Johan Lindstrom
What's the smallest one that
didn't work out so well? What did you do then?
I dunno. What one does then is roll the code back to some good state, then
either try again, or try something else for a while and possibly come back
to it.

The book Refactoring specifies the smallest edits possible between a test
partly to stay safe, and partly to be interruptible. If your refactor is
very big, you must be prepared to release a version, or change tasks, in mid
refactor.

http://www.c2.com/cgi/wiki?DeprecationRefactor

--
Phlip
http://www.c2.com/cgi/wiki?TestFirstUserInterfaces



To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Russel Hill
2003-05-03 16:35:04 UTC
Permalink
Post by Johan Lindstrom
What is a large refactoring, and when is it too large?
What's the largest refactoring you made work? What's the smallest one that
didn't work out so well? What did you do then?
Largest refactoring that worked....

The control software for a legacy system was frequently causing the
error flags to be set in the custom hardware. The original
implementation had many hundreds (1000+, maybe) of memory mapped I/O
points. All of these were implemented as simple C++ pointer
dereferences. I did the folloing in order to instrument them in such a
way that we could track down the cause of the error:

- Implemented a handful of low level access methods on the hardware and
instrumented those.
- Implemented a stl style /container/ class for I/O points.
- Implemented an iterator class similar to the vector<bool>
specialization (along with it's companion reference class).
- Changed every I/O point to be the appropriate IO container and/or
iterator.

This refactoring took several weeks. Interestingly we were able to
prove that the hardware error flags were useless as implemented. The
PCI bus handled the errors, we didn't need to. Several months later,
there was a problem integrating with a new (faster) CPU. As a result of
the refactoring, we were able to fix this problem in just a morning. I
was really lucky with this one. It was before I had ever heard of XP
and there were no tests to support the refactoring.

Smallest refactoring that didn't work... I'll have to think about that.
I know we've had some, ... recently.



To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Phlip
2003-05-03 16:43:16 UTC
Permalink
Post by Russel Hill
- Implemented a handful of low level access methods on the hardware and
instrumented those.
- Implemented a stl style /container/ class for I/O points.
- Implemented an iterator class similar to the vector<bool>
specialization (along with it's companion reference class).
- Changed every I/O point to be the appropriate IO container and/or
iterator.
This refactoring took several weeks.
This was a DeprecationRefactor. The existing I/O points stayed online during
the first phase, writing an independent replacement. Then the second phase
consisted of finding each point and replacing it with the upgrade,
presumably testing everything after each one.

Halfway thru the second phase, with half the I/O points using the old
system, Russel could have presumably released.
Post by Russel Hill
Interestingly we were able to
prove that the hardware error flags were useless as implemented. The
PCI bus handled the errors, we didn't need to. Several months later,
there was a problem integrating with a new (faster) CPU. As a result of
the refactoring, we were able to fix this problem in just a morning.
And that was the third phase of DR - letting the new simplifications ripple
thru the system.

--
Phlip
http://www.c2.com/cgi/wiki?TestFirstUserInterfaces



To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Alex Chaffee / Purple Technology
2003-05-03 16:46:36 UTC
Permalink
What's the smallest one that didn't work out so well?
Rename symbol.
What did you do then?
Rename symbol.

(or Undo)

(This happens at least 3 times every time I refactor.)

To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Phlip
2003-05-03 16:48:56 UTC
Permalink
Post by Alex Chaffee / Purple Technology
What's the smallest one that didn't work out so well?
Rename symbol.
D'OH !!
Post by Alex Chaffee / Purple Technology
What did you do then?
Rename symbol.
Those refactorers have an answer for everything.
--
Homer Simpson


To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
y***@jhrothjr.com
2003-05-03 19:02:51 UTC
Permalink
----- Original Message -----
From: "Johan Lindstrom" <***@yahoogroups.at.jhrothjr.com>
To: "***@yahoogroups.com"
<***@yahoogroups.at.jhrothjr.com>
Sent: Saturday, May 03, 2003 12:12 PM
Subject: [XP] Large refactorings
Post by Johan Lindstrom
What is a large refactoring, and when is it too large?
What's the largest refactoring you made work?
Well, the largest one was in a macro set we used to write
data transformation programs in IBM Assembler.

I had to rework it to free up base registers. Talk about
people not knowing how to work with the architecture!
Probably touched half of the major macros. Took about a week.

The only tests we had were full data before and after
data runs, but fortunately we had a known list of "demon"
cases: transformation programs using the macro set
that would break anything the least bit odd. If all of those
ran, the odds any of the other thousand or so would break
was rather small.
Post by Johan Lindstrom
What's the smallest one that
didn't work out so well? What did you do then?
Since I tend to lead with my chin from long before
anyone heard the word "refactoring," I have way too
many cases of where a cleanup didn't work, of all
sizes and shapes. So you restore to the last working
version and try something else.

John Roth




To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Phlip
2003-05-03 19:33:14 UTC
Permalink
Post by y***@jhrothjr.com
So you restore to the last working
version and try something else.
We seem to be unanimous about "what to do when the refactor fails".

Put it this way: If the reason for failure is not obvious and simple, hit
the Undo button and try again. Anything is preferable to debugging, and an
ounce of prevention is worth a pound of cure.

--
Phlip
http://www.c2.com/cgi/wiki?TestFirstUserInterfaces



To Post a message, send it to: ***@eGroups.com

To Unsubscribe, send a blank message to: extremeprogramming-***@eGroups.com

ad-free courtesy of objectmentor.com

Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
Continue reading on narkive:
Loading...