Refactoring is a disciplined technique for restructuring existing code, altering its internal structure without changing its external behavior. Open-ended questions about refactoring your code are off-topic for Stack Overflow, however they may be appropriate for Code Review.
When should I use this tag?
Refactoring questions may or may not be on-topic for Stack Overflow. To be suitable, questions must be specific. An open-ended question such as "How can I improve this [working] code?" is off-topic on Stack Overflow. It may be appropriate for Code Review.
What is refactoring?
The heart of the method is a series of small behavior preserving transformations. Each transformation (called a 'refactoring') does little, but a sequence of transformations can produce a significant restructuring. Since each refactoring is small, it's less likely to go wrong. The system is also kept fully working after each small refactoring, reducing the chances that a system can get seriously broken during the restructuring.
From the Refactoring Home Page.
Keeping the system in a consistent and correct state is ensured by unit testing after each change.