My go-to methods of refactoring are all about clarity and organization:
1. Rename for clarity of intent
2. Extract to eliminate duplication, and to push down implementation details
3. Compose to achieve a single level of abstraction (SLAP)
These refactorings are fairly simple and safe to do, especially if you have local variables or limited scope variables. If you have an
IDE that can do automatic refactoring, all the better, since that's much safer than manual refactoring. If you're not disciplined and methodical, manual refactoring is dangerous and could lead to breaking the current functionality.
It's important to have tests that will tell you if you broke something while you were refactoring. Without that safety net, refactoring is risky at best. Rename and Extract + Compose are the least risky of all refactorings I know and they can help you loosen up tightly coupled code enough to be able to add unit tests for isolated sections of the code.