Skip to main content

Section 5.2 Facilitating change

We will answer the second question first: You need a thorough suite of automated tests:
In order to ensure that if your changes break existing functionality you will know about it in time, you need an exhaustive set of automated tests, that you can run at a moment’s notice, and that all but guarantee that if they pass then your code meets its requirements.
In other words it’s not enough to "have tests", but you need to have tests that you trust with your life.
We will discuss designing such a suite of tests at a later chapter. For now you should know that in Java you will be writing these unit tests using the JUnit testing framework.
The first question is more complicated, but it effectively centers around a few key ideas:
  • You need a set of refactoring tools, which allow us to make small safe changes to our code’s structure without changing our code’s behavior. These allow us to change our code in small ways. Put enough of these together, and now you start changing the software in big ways. We will discuss refactoring more in the next chapter.
  • You need a set of principles to follow, to guide you towards clean designs, which then facilitate change. We will see a number of these design principles as we go through the chapters.
  • You need a set of established solutions to common problems, along with an understanding of the tradeoffs involved in using these solutions. This is typically the topic of design patterns, and we will examine a number of these patterns as we go through the chapters.
  • Finally, you need to keep your design as simple as possible. This will allow you to more easily enhance it later when you need to.
And this is it! These ideas are exactly what the rest of this book is going to be about. So when you are ready, turn the page and let’s get to work!