From the course: Test-Driven Development in Spring Boot with JUnit and Mockito
Unlock this course with a free trial
Join today to access over 24,900 courses taught by industry experts.
Refactor phase: Improve the code quality
From the course: Test-Driven Development in Spring Boot with JUnit and Mockito
Refactor phase: Improve the code quality
- [Instructor] Alright, time for refactoring. Now that our test is green, we do need to go and review the code in the divide methods. Refactoring isn't about making it work. I mean, it's working already. Refactoring is about improving the structure without changing the external behavior. Let's have a look at the Calculator class and see if we can see room for improvements. Oh, well there is, there's no need to declare the result up top. We can simply return it directly like this. And yes, of course this refactoring phase is more work when you implement an actual feature instead of a divide method that's being implemented for the sole purpose of demonstrating TDD. But I promise you we'll see better examples of refactoring in the next chapters. And now it's time for our next cycle. Let's repeat.