Are your controllers looking like this?
Coding an app in Rails is always fun... for the first 3 months.
After some time, small, little things show up. The tests are no longer below 1 minute. Thin controllers are not really so thin anymore. Single Responsibility Principle is more of a not-so-funny joke than something that you can apply to your Rails models.
The build is taking so long at your machine, that you've almost automated it to immediately open Twitter, gmail, FB, HackerNews because nothing else can be done during the tests.
The speed of adding features slows down. It's no longer fun to demonstrate new features to the Customer.
Your development plan for this release sounds so great. The users could be so happy with the new features. Your code could be so elegantly designed.
Is this really all you did this week?
"Can we agree that we keep controllers thin?" - the team starts to have those little arguments. The model callbacks are killing you. They started simple and now you just keep adding the conditionals.
How can we unit test if it's all coupled together?
You'd love to unit test your models and controllers, but something doesn't feel right about the endless section of mocks, stubs. User.should_receive(this), should_receive(that). It feels like repeating the code. What's the point of such tests?
How do other Rails developers deal with such problems? Rails conventions are great at the start, after that you're on your own.
This shouldn't be so hard!
What if you could have speedy and intuitive conventions even after the app grew over time?
If you had conventions, you would spend less time moving code from one place to another, hoping that you will hide it somewhere. Less time arguing in the team means more features being delivered. More features means happy customers. We want to have happy users and customers.
What if you could add features as fast as at the start?
Fearless Refactoring: Rails Controllers - the book
It's possible to have the same speed of delivering features over time and the "Fearless Refactoring: Rails Controllers" book will teach you how.
This book contains a distilled knowledge taken from reliable architectures, like DDD, Hexagonal Architecture, DCI. I spend years researching those topics with one goal.
Make your application better, simply, step-by-step, under control.
I took what's best from the popular architectures, got rid of things that don't fit well with the Rails specifics and prepared recipes how to deal with a messy Rails code.
Who has time to stay on top of all the latest articles, ideas, and code samples? You need good, working, easy to change code.
This book is a step-by-step guide how to introduce a service layer in your existing Rails app. Every step is described in every detail, with code changes. All of that, so that you can safely refactor your codebase, even without a full test coverage.
This is a beta book. It's not quite finished but I wanted to get it into your hands so you can start using it. As an early adopter, you get a discount, all updates and access to the final copy
Buy now for only
$49 $35 in PDF, epub and mobi.
If my book doesn't help you with your Rails code, I'll refund you 100%.
About the author
Andrzej Krzywda is the founder and CEO of Arkency, a Rails consultancy.
He spends time reviewing dozens of legacy Rails apps every year, finding patterns, applying fixes.