Guide to Refactoring
An ongoing curated list of awesome frameworks, important books and articles, talks and videos, libraries, learning tutorials, coding best practices and technical resources about Refactoring.
Thanks to our daily readers and contributors. The goal is to build a categorized community-driven collection of very well-known resources. Sharing, suggestions and contributions are always welcome!
Definition
There are a few definitions of refactoring (in practice very similar). The most popular is a 2-part definition by Martin Fowler:
Refactoring (noun): a change made to the internal structure of software to make it easier to understand and cheaper to modify without changing its observable behavior.
Refactoring (verb): to restructure software by applying a series of refactorings without changing its observable behavior.
Books
- Refactoring: Improving the Design of Existing Code by Martin Fowler and Kent Beck - the refactoring book, that presented the concept of refactoring to wider audience. Available in 2 editions: 1st contains examples in Java, 2nd in JavaScript. Must-read for any adept of software engineering
- Refactoring Workbook by William C. Wake - a workbook that uses the 1st edition of "Refactoring" book as a reference
- Refactoring to Patterns by Joshua Kerievsky - combines the practice of refactoring with object-oriented design patterns. The book presents real-life problems and solutions showing a total of 27 refactoring techniques
- Refactoring: Ruby Edition by Jay Fields, Shane Harvie, and Martin Fowler, with Kent Beck - the Ruby-specific edition of the original "Refactoring" book with a few techniques added and of course examples adapted so that they're more useful in Ruby
- Refactoring to Rust by Nate Mara (currently in early access program, as of March 2021) - this book focuses on iterative adoption of Rust via its interop mechanisms
- Refactoring at Scale by Maude Lemaire - this book talks about refactoring in large and complex codebases, with examples from author's experience at Slack
- Refactoring TypeScript: Keeping Your Code Healthy by James Hickey
- Refactoring JavaScript: Turning Bad Code Into Good Code by Evan Burchard
- Refactoring for Software Design Smells by Girish Suryanarayana, Ganesh Samarthyam, and Tushar Sharma
- Refactoring to Collections by Adam Wathan - this book (+ videos) focus on refactoring PHP code to use modern collection library (used, among others, by Laravel framework)
- Refactoring Databases: Evolutionary Database Design by Pramod Sadalage - this book talks about refactoring on the database level instead of code level,
Websites
- Refactoring.com - part of Martin Fowler's website, contains a catalog of 60+ techniques; free version provides simple examples, paid version contains description, mechanics and more. Most of tecnhiques are available in the "Refactoring" book.
- Refactoring Guru - contains 60+ techniques, each with description, implementation and a simple example + around 20 code smells with description and suggested refactorings that help to get rid of it
Articles
- It's Not Refactoring, It's Untangling, by Cody Powell
- What Are We Doing with All These Tests? (And, Refactoring) by Harry J. W. Percival - this is part of the Test-Driven Development with Python book that talks primarily about TDD, but also covers the topic of refactoring
- Examples of Refactoring PHP Code for Better Readability by Gilbert Pellegrom - a few refactoring techniques with examples in PHP
- Let's Not Misuse Refactoring by German Velasco - interesting article that explores what do we really mean when we say that refactoring does not change observable behaviour of our code
- Code Refactoring by Arvind Padmanabhan - Devopedia article describing the concept and history of refactoring; it also provides answers to some common questions about the topic
- Refactoring by the Book by Marcos Matos - the article talks about refactoring while keeping tests green (almost) the whole time
Others
- How to justify code refactoring time? - discussion and advice on justifying refactoring (Stack Exchange)
- History of Refactoring - C2 wiki post about beginnings of refactoring (I am not sure how accurate it is regarding the first use of the term "refactoring")
Quotes
- Don't live with broken windows. - Andy Hunt & Dave Thomas
- A Fallacy of Software: If it works, and we don't change anything, it will keep working. - Jessica Kerr
- Cities grow, cities evolve, cities have part that simply die while other parts flourish; each city has to be renewed in order to meet the needs of its populace. ... Software-intensive systems are like that. - Grady Booch
- You think refactoring legacy software is bad. Try refactoring legacy culture. - Larry Garfield
- We're changing what the code says without changing what it does. - Michael D. Hill
- One of my most productive days was throwing away 1000 lines of code. - Ken Thompson
- Refactoring - the process of taking a well-designed piece of code and, through a series of small, reversible changes, making it completely unmaintainable by anyone except yourself. - Jason Gorman
License
MIT License & cc license
This work is licensed under a Creative Commons Attribution 4.0 International License.