Home > Store

Rails AntiPatterns: Best Practice Ruby on Rails Refactoring, Rough Cuts

Rails AntiPatterns: Best Practice Ruby on Rails Refactoring, Rough Cuts

Rough Cuts

  • Available to Safari Subscribers
  • About Rough Cuts
  • Rough Cuts are manuscripts that are developed but not yet published, available through Safari. Rough Cuts provide you access to the very latest information on a given topic and offer you the opportunity to interact with the author to influence the final publication.

Not for Sale


  • Copyright 2010
  • Dimensions: 7 X 9-1/4
  • Pages: 384
  • Edition: 1st
  • Rough Cuts
  • ISBN-10: 0-321-62028-3
  • ISBN-13: 978-0-321-62028-6

This is the Rough Cut version of the printed book.

The Complete Guide to Avoiding and Fixing Common Rails 3 Code and Design Problems

As developers worldwide have adopted the powerful Ruby on Rails web framework, many have fallen victim to common mistakes that reduce code quality, performance, reliability, stability, scalability, and maintainability. Rails™ AntiPatterns identifies these widespread Rails code and design problems, explains why they’re bad and why they happen—and shows exactly what to do instead.

The book is organized into concise, modular chapters—each outlines a single common AntiPattern and offers detailed, cookbook-style code solutions that were previously difficult or impossible to find. Leading Rails developers Chad Pytel and Tammer Saleh also offer specific guidance for refactoring existing bad code or design to reflect sound object-oriented principles and established Rails best practices. With their help, developers, architects, and testers can dramatically improve new and existing applications, avoid future problems, and establish superior Rails coding standards throughout their organizations.

This book will help you understand, avoid, and solve problems with

  •  Model layer code, from general object-oriented programming violations to complex SQL and excessive redundancy
  • Domain modeling, including schema and database issues such as normalization and serialization
  • View layer tools and conventions
  • Controller-layer code, including RESTful code
  • Service-related APIs, including timeouts, exceptions, backgrounding, and response codes
  • Third-party code, including plug-ins and gems
  • Testing, from test suites to test-driven development processes
  • Scaling and deployment
  • Database issues, including migrations and validations
  • System design for “graceful degradation” in the real world

Sample Content

Table of Contents

Foreword         xi

Introduction         xiii

Acknowledgments          xvii

About the Authors          xix

Chapter 1: Models         1

AntiPattern: Voyeuristic Models   2

AntiPattern: Fat Models   14

AntiPattern: Spaghetti SQL   31

AntiPattern: Duplicate Code Duplication   50

Chapter 2: Domain Modeling         73

AntiPattern: Authorization Astronaut   74

AntiPattern: The Million-Model March   79

Chapter 3: Views         89

AntiPattern: PHPitis   91

AntiPattern: Markup Mayhem   107

Chapter 4: Controllers         117

AntiPattern: Homemade Keys   118

AntiPattern: Fat Controller   123

AntiPattern: Bloated Sessions   154

AntiPattern: Monolithic Controllers   161

AntiPattern: Controller of Many Faces   167

AntiPattern: A Lost Child Controller   170

AntiPattern: Rat’s Nest Resources   180

AntiPattern: Evil Twin Controllers   184

Chapter 5: Services         189

AntiPattern: Fire and Forget   190

AntiPattern: Sluggish Services   195

AntiPattern: Pitiful Page Parsing   197

AntiPattern: Successful Failure   201

AntiPattern: Kraken Code Base 207

Chapter 6: Using Third-Party Code         211

AntiPattern: Recutting the Gem   213

AntiPattern: Amateur Gemologist   214

AntiPattern: Vendor Junk Drawer   216

AntiPattern: Miscreant Modification   217

Chapter 7: Testing         221

AntiPattern: Fixture Blues   223

AntiPattern: Lost in Isolation   236

AntiPattern: Mock Suffocation   240

AntiPattern: Untested Rake   246

AntiPattern: Unprotected Jewels   251

Chapter 8: Scaling and Deploying         267

AntiPattern: Scaling Roadblocks 268


Submit Errata

More Information