Jump to ratings and reviews
Rate this book

Recipes for Decoupling

Rate this book
Software is never done. The world around your program changes faster than you want it to. Frameworks and libraries are abandoned and replaced with something better (or just something new), so you need to migrate. You can postpone this work for a bit, but eventually you'll have to catch up, or your project may end up hopelessly outdated. I'm sure you know one or two of those projects!

How can you make all of this easier for yourself and the future maintainers of the project? The keyword is "decoupling". You can change the design of your code to defend it against changes in any dependency your project relies on. Decoupling your code is a way to make it future-proof (without doing too much work that "you ain't gonna need").

About 10 years ago I started looking for ways to decouple my code, but at first I struggled to do it effectively. My code was decoupled in the wrong places, or in the wrong way. I got a better view on this topic after several intense experiences with some legacy projects, a big framework migration, and a complete project rewrite (that I'm sure could have been prevented). I've collected many recipes for decoupling along the way. This book gives you a practical overview of common situations that suffer from an often unintended high level of coupling in web applications. Of course, it also gives you step-by-step recipes to improve these situations. The examples in this book show you how to decouple from your web framework, templating engine, test framework, ORM, and so on.

Decoupling is one thing, but staying decoupled is something else entirely. That's why in this book we focus on how to solidify the decoupling rules with PHPStan, the automated static analysis tool for PHP. That way we don't have to rely on discipline and code reviews, but can let a tool point out possible coupling mistakes.

303 pages, Paperback

Published July 28, 2022

3 people are currently reading
33 people want to read

About the author

Matthias Noback

10 books43 followers

Ratings & Reviews

What do you think?
Rate this book

Friends & Following

Create a free account to discover what your friends think of this book!

Community Reviews

5 stars
5 (45%)
4 stars
3 (27%)
3 stars
3 (27%)
2 stars
0 (0%)
1 star
0 (0%)
Displaying 1 - 3 of 3 reviews
11 reviews
November 22, 2022
After enjoying insightful blog posts and Twitter threads on refactoring and working with modern and legacy PHP systems, this is the first proper book written by Matthias Noback that I've read. While I knew a good chunk of the involved refactorings already, some of the recipes were completely new to me and made me want to apply them immediately to one of my code bases.

What I appreciated a lot are the step-by-step guides through writing PHPStan rules, something I've wanted to do before but failed at. With these guides, I'll be sure to write some rules that might help make my code base easier to manage.
Profile Image for Gary Jones.
40 reviews
July 9, 2023
I ordered and expensed this for work. I was already a fan of the author before, and this book is like his other books and blog posts. Even if you are only vaguely aware of Symfony, Laravel, and Doctrine, there is still value and knowledge to be gained. A fair chunk of the book is how to set up custom rules to protect against future coupling mistakes, so these sections can be skimmed/skipped until your ready to apply them.
Profile Image for Greg.
8 reviews10 followers
December 16, 2023
Could be also subtitled guide to writing custom phpstan rules
Displaying 1 - 3 of 3 reviews

Can't find what you're looking for?

Get help and learn more about the design.