Reputation: 1922
I wonder how do programmers refactor code that is written in languages like Ruby, Python?
Assuming you get code after a 'previous' guy—so you cannot be sure about quality of tests and their coverage.
Do you use any specific approach?
Upvotes: 3
Views: 1692
Reputation: 40336
Without an IDE, you will have to take smaller steps, well protected by comprehensive unit tests. Martin Fowler's Refactoring, written before all the software tools were available, is a pretty good guide to how to refactor safely. You take small steps, checking all along that you're not breaking anything, frequently leaving original code in place until the replacement has been completed. It's tedious but doable.
Upvotes: 3
Reputation: 6856
in vim
you can use the following command to search for things:
/spock
and get all instances of spock by pressing n
to cycle through the file.
To search and replace, you can use this:
:%s/spock/kirk/g
which will replace all instances of spock with kirk. Vim has some pretty powerful stuff, but you can also use find/sed/grep to do entire directories or projects.
Good luck!
Upvotes: -1