Guide on Refactoring for PMI-ACP/TDD Exam
What is Refactoring?
Refactoring is a practice in Test-Driven Development (TDD) wherein the code is improved without changing its external behavior. It enhances code readability and reduces complexity, thus making it easier for further modification.
Importance of Refactoring:
Refactoring aids in minimizing the technical debt of a project by making the code more maintainable and expendable. It also facilitates the easy identification of software bugs and aids in improving software design.
How Refactoring Works:
Refactoring process works on the 'Red, Green, Refactor' cycle in TDD. When an addition or improvement in function is needed, code is first tested (red), then written to pass the test (green), followed by refactoring to eliminate any duplication or complexity.
Exam Tips: Answering Questions on Refactoring
1. Understand that refactoring doesn't change the external behavior of the code.
2. Be sure to decipher between refactoring and rewriting as they are not the same. Rewriting involves changes in code behavior, while refactoring improves code without changing functionality.
3. Remember the 'Red, Green, Refactor' cycle as it is a key element in TDD approach.
4. Refactoring is primarily performed to reduce complexity and improve maintainability and expendability of code.