Saturday, October 12, 2013

New eBook: Software As A Disservice - Fixing A Broken Rails App

I wrote a new (e)book, called Software As A Disservice: Fixing A Broken Rails App. It's a caffeine-fueled foray into fixing legacy code. I wrote it partly because I have some Rails students who I'm training, and I wanted to show them the difference between bad Rails code and good Rails code. I also wrote it because I was a little bit outraged by somebody else's ebook.

I started with this open source Rails app, an allegedly good example of a subscription site using Stripe. The "allegedly good" part, btw, is not alleged by Stripe, but by the app's author, who also sells a subscription (using the app itself) to a site with tutorials on how to build Rails apps, including an ebook about building the subscription site app in the first place.

It's a wonderfully meta business model, and I love how it involves giving code away for free. But the code is, in my opinion, awful, and anybody who used it as an example of how to build Rails apps would be misled about how Rails apps should be architected and how Rails code should look. In my opinion, this app does you a serious disservice if you take it at face value, so I called my book Software As A Disservice.

In this book, I take this app's open source code, and work hard to make it suck less.

The book itself is only about 120 pages, which only gave me enough space to make significant progress in both re-architecting and refactoring the User model. If you've refactored and/or re-architected a bunch of legacy Rails sites already, you might not learn anything; this is probably not the book for you. You should buy this if you're new to Rails, and you want to understand the difference between good Rails code and bad Rails code.

Caveat: this book is full of foul language. One chapter is called "Why The User Model Is Fucked." There are also garish, violent, and sexual metaphors involving raccoons, bananas, anal sex, dangerous machinery, weapons, and tentacles. There's probably other disturbing and/or inappropriate stuff that I forgot about, and it's entirely possible that a reasonable person could read this book and worry about my mental health. However, as long as you learn something about writing good Rails apps in the process, I can basically live with that.

The book's crazy like that because I wanted it to be funny, I wanted it to be candid, and I wanted it to feel kind of live and real-time. I wrote it while fixing the app in question, and if you think it's possible to fix legacy code without swearing a lot, you're either some supernatural entity of the holy variety yourself, or you're fucking dreaming. Anyway, the benefit of the "live and real-time" factor is that the book's annotated with git commit hashes, so you can go through the code, do a git checkout xyz12345 to explore the code at every stage in the process, and/or see exactly how the code changes from moment to moment with git diff.

The book's only in PDF format; I've upgraded my toolchain to make mobi and epub output possible as well, but it won't be ready for a little while longer. I'm going to release both this book and Rails As She Is Spoke in Kindle format for sure, but epub format remains a maybe, and I'm not sure how many of my other books will also get converted. Anyway, Software As A Disservice is 122 pages long, it's aimed for newbie to intermediate Rails devs, and it's $23.

To buy Software As A Disservice: Fixing A Broken Rails App for $23:

To promote it, I'm also selling a bundle of Software As A Disservice along with my other two Rails books, Rails As She Is Spoke and Unfuck A Monorail For Great Justice. That's $61; the total to buy those books individually is $101. So you save exactly $40 if you buy the bundle.

To buy the bundle and save $40: