From the course: Practical Test-Driven Development for Java Programmers

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Introducing refactoring

Introducing refactoring

- [Narrator] Hello, welcome back. We're now in the position that we've implemented quite a bit of logic and we have a suite of passing tests. Now, it's time to refactor our code. As we'll see there's a great benefit of having these suites of tests in this stage. As every time we make a change to the code that we've written, we can use our test to check that we haven't broken anything. This gives us confidence that as we make changes, we're not introducing new bugs into the code. So, in this chapter we're going to use some common refactorings to improve our code. I want to make our code more readable, or clearer to understand what each part of the code is doing so that it'll be easier to maintain going forward. I think that our starting point should be that we can extract some of this code into separate methods. Let's take this code block here, for example. Within the if statement for the length being 13. This code is dealing with a question "is this a valid 13 digit ISBN number?" So…

Contents