Channels ▼

Mike Riley

Dr. Dobb's Bloggers

Rails AntiPatterns Book Review

December 22, 2010

With Ruby on Rails firmly entrenched in the web application development scene, books on the subject are migrating from introductory tutorials to deeper, more advanced studies on the topic. Rails AntiPatterns: Best Practice Ruby on Rails Refactoring is one such book. Does its educational value match its cover price? Read on to find out.According to the Chad Pytel and Tammer Saleh, the book's authors who base the definition's source on an earlier AntiPatterns title, an AntiPattern is "a repeated pattern of action, process, or structure that initially appears to be beneficial but ultimately produces more bad consequences than beneficial results". An AntiPattern must also have "a refactored solution that is clearly documented, proven in actual practice, and repeatable." Essentially, Rails AntiPatterns is a variant on the Problem/Solution technical cookbooks that focuses on frequent issues and bad habits that developers unintentionally bake into Rails projects. This ten chapter book dives into all aspects of Rails development and deployment where such AntiPatterns show up.

The first chapter, the largest in the book, hits the ground running with Model AntiPatterns: Voyeuristic and Fat Models, Spaghetti SQL and Duplicate Code Duplication. Domain Modeling explores two AntiPatterns: Authorization Astronaut and The Million-Model March. Chapter 3 on Views coves PHPitis and Markup Mayhem. Controllers presents eight AntiPatterns including Bloated Sessions, Rat's Nest Resources and Evil Twin Controllers. Chapter 5 on Services contains five services-related AntiPatterns such as Pitiful Page Parsing and Successful Failure. The chapter on Using Third Part Code offers four AntiPatterns, Chapter 7 (Testing) has five such as Fixture Blues and Unprotected Jewels and Chapter 8 (Scaling and Deploying) discusses four more, such as Disappearing Assets and Sluggish SQL. Chapter 9 contains two Database Antipatterns (Messy Migrations and Wet Validations), and the final chapter (Building for Failure) offers up two more AntiPatterns (Continual Catastrophe and Inaudible Failures). Each of the 38 AntiPatterns follows the same AntiPattern/Solution format, first discussing the AntiPattern in detail including the reasons and outcomes of the problem followed by a often deeply technical exposition on the solution.

The book works on a number of levels. First, anyone who has been writing Rails applications beyond small departmental one-offs has encountered at least a few of the AntiPatterns identified by the authors. While you could spend hours on Google searching for a solution (assuming you know exactly what your problem is and the question that needs to be asked), knowing these patterns up front could save a lot of time, hair and sanity. Second, the authors obviously have deep knowledge of and passion for Rails, and this translates well on the page. They empathize with the readers, recounting from their own AntiPattern wrestling matches how these problems can really put a damper on your Rails productivity and enthusiasm. And most importantly, unlike various problem/solution cookbooks written by many contributors, Rails AntiPatterns maintains a comfortable and colloquial conversation with the authors. I pictured them speaking with me during the lobbytrack of a Rails conference over problems they encountered and the introspective solutions they discovered. Sharing these with the readers, especially the ones about fixtures and failures ("never fail quietly"), were most memorable.

Beginning Rails developers might not be able to fully appreciate the insights the authors share, but intermediate and advanced Rails programmers will be nodding their head in some sections, saying 'so that's why' in others and thinking 'oh, that's something I'll have to remember to avoid' while reading several more. Dedicated Rails developers should not hesitate adding Rails AntiPatterns to their bookshelf.

Title: Rails AntiPatterns: Best Practice Ruby on Rails Refactoring Authors: Chad Pytel and Tammer Saleh Publisher: Addison-Wesley Professional ISBN: 978-0-321-60481-1 Pages: 400 Price: $35.99 (Ebook), $44.99 (Print)

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.