Refactoring is a disciplined technique for restructuring an existing body of code, altering its internal structure without changing its external behavior.
When you should refactor? There are list of situations when you certainly should. Martin Fowler calls them Bad smells in code. Here they are: