Search⌘ K

Refactor and Improve the Code

Explore how to effectively refactor both code and tests in Django applications without altering functionality. Understand when and why refactoring is important, and learn to ensure your tests continue to pass after improvements, supporting clean and reliable code.

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 ...