[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[FR-devel] Thoughts on refactoring
From: |
Hal E. Fulton |
Subject: |
[FR-devel] Thoughts on refactoring |
Date: |
Fri, 30 Aug 2002 18:47:09 -0500 |
Here are some miscellaneous thoughts.
Disclaimer: I've never used a real IDE
that did automatic refactoring.
I did long ago play with a tool called
Alice Pascal (ca. 1985) which was years
ahead of its time in many ways.
It seems to me that there are at least
two kinds of refactoring:
1. Global stuff, like change the name
of this method everywhere, etc.
2. Local stuff, like change the nature
of this piece of code in a highly
specific way.
By the way, I think many of the items
from the Fowler book will be applicable,
in addition to the ones someone pasted
into the wiki from the Java tool.
Some examples of #2 above:
a. I'd like to be able to highlight a
group of lines and apply an operation
to protect it by catching exceptions
(leaving blanks for me to fill in).
foo()
bar()
bam()
# becomes...
begin
foo()
bar()
bam()
rescue
end
b. I'd like to be able to transform
control structures into equivalent
code using different structures (tests,
loops, ...) For example, I wish I had
used a case instead of an if:
if x==1
foo()
elsif x==2
bar()
else
bam()
end
# becomes...
case x
when 1
foo()
when 2
bar()
else
bam()
end
c. One thing I sometimes find myself doing
is converting to (and from) multiple assignment
form. I'd like to be able to highlight
a=1
b=2
c=3
# and have it become
a, b, c = 1, 2, 3
# or vice versa
Just some more thoughts.
Hal
- [FR-devel] Thoughts on refactoring,
Hal E. Fulton <=