Refactor and Improve the Code

Learn to refactor and improve the code in test-driven development.

This isn’t a required step because not all code necessarily needs to be refactored. However, when there is a need to improve the code without changing the underlying functionality, we can refactor the code. This process goes hand in hand with the test written in the first step because while refactoring the code, we make sure that we still have a passing test.

How does it work?

Refactoring helps remove duplicates. When refactoring, we can either work on the code or on the tests. However, it’s recommended not to work on both ...