Master Refactoring Through Books

Refactoring for professional programming

Mustafa Katipoğlu
Cyber Architect
5 min readJan 10, 2022

--

Photo by Rick Rothenberg on Unsplash

Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.

— Antoine de Saint-Exupéry

Refactoring is one of the core skills of skilled programmers. As the speed of change increases in software, so does the importance of refactoring. For programmers, refactoring has become a must-have skill to survive at the current speed of the change we observe in the software landscape.

Even though the basic principles behind refactoring may seem easy to apply, it is not the case. The refactoring itself requires special attention on its own to master it thoroughly.

Refactoring Manifesto

The Refactoring Manifesto well describes the motivation behind refactoring.

1. Make your products live longer!

Refactoring means taking the opportunity to keep your product alive. Don’t ditch it, stitch it! Don’t end it, mend it!

2. Design should be simple so that it is easy to refactor.

Product designers: Make your products easy to change. Write clean, understandable code.

Consumers: Buy products that are continuously refactored, or else find out why the developers didn’t do that. Be critical and inquisitive.

3. Refactoring is not rewriting.

Rewriting is throwing away the broken bit. This is NOT the kind of refactoring that we’re talking about.

4. What doesn’t kill it makes it stronger.

Every time we refactor code, we add to its potential, its history, its soul and its inherent beauty.

5. Refactoring is a creative challenge.

Refactoring is good for the imagination. Using new techniques, tools and materials ushers in possibility rather than dead ends.

6. Refactoring survives fashion.

Refactoring is not about styling or trends. There are no due-dates on continuously refactored code.

7. To refactor is to discover.

As you refactor objects, you’ll learn amazing things about how they actually work. Or don’t work.

8. Refactor — even in bad times!

If you think this manifesto is not relevant during recession, forget it. This isn’t about effort, it’s about mentality.

9. Refactoring is about independence.

Don’t be a slave to legacy code — be its master. If it’s broken, refactor it and make it better. And if you’re a master, empower others.

10. You can refactor anything, even total crap.

But we’d recommend avoiding total crap. Refactoring stops code from becoming crap.

Refactoring: Improving the Design of Existing Code

Refactoring: Improving the Design of Existing Code By Martin Fowler

Refactoring is the process of changing a software system in a way that does not alter the external behavior of the code yet improves its internal structure. It is a disciplined way to clean up code that minimizes the chances of introducing bugs. In essence, when you refactor, you are improving the design of the code after it has been written.

With refactoring, we can take a bad, even chaotic, design and rework it into well-structured code. Each step is simple — even simplistic. I move a field from one class to another, pull some code out of a method to make it into its own method, or push some code up or down a hierarchy. Yet the cumulative effect of these small changes can radically improve the design. It is the exact reverse of the notion of software decay.

With refactoring, the balance of work changes. I found that design, rather than occurring all up front, occurs continuously during development. As I build the system, I learn how to improve the design. The result of this interaction is a program whose design stays good as development continues. [1]

Five Lines of Code

Five Lines of Code By Christian Clausen

Refactoring is the discipline of transforming bad code into good code without breaking it. When we consider that our entire civilization now depends on software for its further existence, it seems unlikely that there is a topic more worthy of study.

This book does not present the kind of sterile and simplistic refactoring you may have heard or read about before. This book talks about real refactoring. Refactoring in real projects. Refactoring in legacy systems. Refactoring in the kinds of environments that we all face virtually every day. [2]

Refactoring to Patterns

Refactoring to Patterns By Joshua Kerievsky

This book is about the marriage of refactoring — the process of improving the design of existing code — with patterns, the classic solutions to recurring design problems. Refactoring to Patterns suggests that using patterns to improve an existing design is better than using patterns early in a new design. This is true whether code is years old or minutes old. We improve designs with patterns by applying sequences of low-level design transformations, known as refactorings. [3]

Refactoring Databases: Evolutionary Database Design

Refactoring Databases: Evolutionary Database Design By Scott W. Ambler, Pramod J. Sadalage

Refactoring Databases is an invaluable resource that shows data professionals just how they can leap ahead and confidently, safely embrace change. Scott and Pramod show how the improvement in design that results from small, iterative refactorings allow the agile DBA to avoid the mistake of big upfront design and evolve the schema along with the application as they gradually gain a better understanding of customer requirements. [4]

Sachin Rekhi

Related

References

[1] Refactoring: Improving the Design of Existing Code : Preface

[2] Five Lines of Code : Foreword

[3] Refactoring to Patterns : Preface

[4] Refactoring Databases: Evolutionary Database Design : Preface

--

--