Chapter 7: It Takes Forever to Make a Change

Chapter 7: It Takes Forever to Make a Change

Note of Working Effectively with Legacy Code

Understanding

The author told us that the most significant difference between a well-maintained system and a legacy system is the time we spend understanding where to make and how to make the change.

We won't be hesitant to implement new features from scratch as long as we have enough knowledge. But if the changes are based on the legacy code, we must understand the existing logic first. That may cost us lots of hours.

Lag Time

The author asked us a question: what is Lag Time? To explain the concept, he gives us an example, the famous Mars rover Spirit; it takes about seven minutes for signals to get from Earth to Mars; that is the Lag Time.

In our daily work, the Lag Time means the interval between our every coding step. We always separate the feature as tiny as possible in a well-maintained system. So there is no need to deal with the complicated logic between every dependency, which will save us lots of time. We can even test a small class without other dependencies being involved. So each movement we make will get quick feedback to tell us if everything goes well.

And for the legacy system, for your consideration, the Mars rover Spirit.

Breaking Dependencies

As we already know, Extracting Interface is an excellent weapon for breaking dependencies. And when we use it, we will find out that we can change one class or method without recompiling the other classes. That will save us lots of time and concentration. And we call this concept The Dependency Inversion Principle.

We already know this concept very well, so there isn't anything to discuss.

Summary

The techniques I’ve shown in this chapter can speed up build time for small clusters of classes, but this is only a tiny portion of what you can do using interfaces and packages to manage dependencies. Robert C. Martin’s book Agile Software Development: Principles, Patterns, and Practices (Pearson Education, 2002) presents more techniques along these lines that every software developer should know.

By the way, it is truly a great book.