Code Refactoring
Code Refactoring
• Duplicate Code
• Long Methods
• Switch Case Statements
• Data Clumping &
• Speculative Generality.
Process of Code Refactoring
Benefits of Code Refactoring
1. Maintainability
It is easier to fix bugs because the source code is easy to read and
the intent of its author is easy to grasp.
2. Extensibility
• Encapsulate Field: force code to access the field with getter and setter
methods
• Generalize Type: create more general types to allow for more code
sharing
• Extract Class moves part of the code from an existing class into a new
class.
• Rename Method or Rename Field changing the name into a new one that
better reveals its purpose.