If you are looking to get into refactoring but don't know where to start, there are a lot of good resources out there to help you get started. Here are three that helped me the most:
Clean Code: This is one of my favorite programming books. I think it's a great book to start with because it will help you answer this question - what is clean code? Until you can answer that, you'll get lost refactoring code because you won't have a clear picture of what you want it to end up with.
Destroy All Software: Fantastic screencasts from Gary Bernhardt. I love DAS because the screencasts are fast, to the point, and often use real code rather than contrived examples. You'll learn how to execute large refactorings in steps and small ones done quickly while fleshing out an idea. The screencast format will help you pick up important things that books often omit such as:
- how to identify code that needs to be refactored
- how and when to run tests
- how an editor can help with refactoring
Refactoring: This is the book that everyone recommends. It has a chapter for each refactoring pattern (e.g. Rename Variable, Extract Temp, etc.) with info on each pattern - why to use it, and what the code looks like before and after the refactoring, and some guidelines. I put this last because I found it a bit boring compared to Destroy All Software.
If you've been trying to refactor your code without much guidance, any of these will quickly help take your refactoring to the next level. Enjoy!