1.1. What Is Prefactoring?

Refactoring is the practice of altering code to improve its internal structure without changing its external behavior. Prefactoring uses the insights you have gleaned from your experience, as well as the experience of others, in developing software. The expertise gained in refactoring is part of that experience.

I have condensed my ideas and the ideas I have heard from many developers over many years into the prefactoring guidelines we will explore in this book. Take them as a starting point to developing your own guidelines. Many guidelines relate to basic design principles, but they are expressed in different fashions. Other guidelines revolve around the concepts of Extreme Abstraction, Extreme Separation, and Extreme Readability. I will talk about those concepts later in this chapter.

Another facet of prefactoring is a concentration on interfaces. By considering interfaces—what components can do for you, instead of how they work—you further the goal of abstraction. Refactoring is also concerned with interfaces; the ones for which you do not change the external behavior, while you are altering the internal implementation.

Applying the guidelines in this book does not guarantee that you will never need to refactor your design or code. You might decrease the amount of refactoring that is required. Can you foresee everything? No. Are the decisions you make today final? No. It is practically impossible to think of everything or know everything in the beginning ...

Get Prefactoring now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.