The Refactoring Tales

“The Refactoring Tales” is a set of refactoring stories grouped into a small book. It’s aim isn’t to teach you coding specifics such as functions, objects, or how to use them, but more so to examine techniques for maintaining code and improving it over time. The book is split into a series of chapters, each looking in particular at one piece of code and telling the story of how it was improved with some simple changes and refactorings.

The book is currently a work in progress (a “beta” version, if you will), but three chapters have been fully written, with another soon to follow. The book is expected to be about 6-7 chapters, each containing a refactoring case study, but will grow over time.

The book is entirely free to read online, and can be done so here. It is also published openly on GitHub. If you find any problems or have any suggestions, please feel free to open an issue on GitHub.

Who should read this book

This book is perfect for people who have grasped the JavaScript basics but would like to learn methods for keeping a codebase clean and maintainable. If you’ve masted the jQuery carousel but want to improve your implementation, this book will help. We’ll look at popular development approaches and principles such as the Single Responsibility Principle, Coupling, Publish and Subscribe, and more. If you’ve struggled to work with some code or found it hard to change your existing code, I’ll discuss how to make your code less resistant to change and more approachable. If you find your code becomes hard to work with as it grows and you add more functionality, this book will help you how to structure your applications from the go to help as they grow.

This book should provide insight and helpful, practical advice regardless of if you write primarily client side JavaScript, JavaScript on the server, or manipulate the DOM with jQuery. It’s framework and library agnostic (although some examples use jQuery, it itself is not important in the context of this book) and although the examples are all written in JavaScript, the principles and approaches can be used in any programming language.