From: Steve Tuckner Date: 2002-09-10T23:28:43+09:00 Subject: Refactoring Ruby This is a multi-part message in MIME format. ------=_NextPart_000_0098_01C258AC.665941E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi all, I have recently been refactoring some ruby code and was looking for pointers or tips on how best to accomplish it. One problem that I have had is finding all references to methods of a class that I was refactoring. For example, if I have defined: class Foo def[](index) # do something in here end end and I wish to change it to: class Foo def get_with_index(index) # do something slightly different end end How do I find all occurances of in the code where objects of type Foo are doing foo[index]? Searching for [] is no help because that is likely all over the code. There are no type declarations to find instances of foo. I can search for Foo.new and follow it through functions, etc but that is often not simple. Unit tests are helpful to see if my code still works, but even with them I don't feel completely secure that I have caught all instances. Any ideas would be useful. Thanks, Steve Tuckner ------=_NextPart_000_0098_01C258AC.665941E0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi=20 all,
 
I = have recently been=20 refactoring some ruby code and was looking for pointers or tips on how = best to=20 accomplish it. One problem that I have had is finding all references to = methods=20 of a class that I was refactoring. For example, if I have=20 defined:
 
class = Foo
    def[](index)
       =20 # do something in here
    end
end
 
and I = wish to change=20 it to:
 
class = Foo
    def get_with_index(index)
       =20 # do something slightly = different
    end
end
 
How = do I find all=20 occurances of in the code where objects of type Foo are doing = foo[index]?=20 Searching for [] is no help because that is likely all over the code. = There are=20 no type declarations to find instances of foo. I can search for Foo.new = and=20 follow it through functions, etc but that is often not=20 simple.
 
Unit = tests are=20 helpful to see if my code still works, but even with them I don't feel=20 completely secure that I have caught all instances.
 
Any = ideas would be=20 useful.
 
Thanks,
 
Steve = Tuckner
------=_NextPart_000_0098_01C258AC.665941E0--