Home > Store > Programming > Ruby

larger cover

Add To My Wish List

Rails AntiPatterns: Best Practice Ruby on Rails Refactoring

Register your product to gain access to bonus material or receive a coupon.

  • Description
  • Reviews
  • Sample Content

Product Author Bios

Chad Pytel is president of thoughtbot, inc., a software development consulting firm that specializes in agile, test-driven web application development using Ruby on Rails. He coauthored Pro Active Record: Databases with Ruby and Rails (Apress, 2007).

Tammer Saleh
is a Ruby on Rails developer who has worked as programmer and system administrator in organizations including the NCSA, Caltech, UIUC, and Citysearch.com. Saleh has spoken at many events, including Railsconf 2007, Scotland on Rails, Mountain West Ruby Conference, and OSCON 2008.

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

Customer Reviews

16 of 16 people found the following review helpful
5.0 out of 5 stars Finally, a Rails book worth reading!!!, March 17, 2011
Amazon Verified Purchase(What's this?)
This review is from: Rails AntiPatterns: Best Practice Ruby on Rails Refactoring (Addison-Wesley Professional Ruby Series) (Paperback)
I'll be honest, prior to reading this book I was starting to lose faith in Ruby on Rails authors. As a beginner to Rails, I've read a number of books to try and make sense of all the black magic going on behind the scenes as well as how to write great code in Rails. Many of those books were either "paint by number" tutorials where you didn't really learn anything appreciable or very complete (and hard to comprehend) reference manuals for everything there is to possibly know about Rails.

I just needed a good in between book! This book not only exposes you to the Rails Way of writing code in Ruby on Rails, it also gives many of the opposing examples which I would more than likely stumble down not knowing any better.

Not only that, but this is one of the most logically organized books I have ever had the pleasure to read. Everything flows together very nicely and is very understandable for beginners let alone more advanced users.

I would recommend... Read more
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


7 of 7 people found the following review helpful
5.0 out of 5 stars Fantastic source of refactoring ideas, December 9, 2010
Amazon Verified Purchase(What's this?)
This review is from: Rails AntiPatterns: Best Practice Ruby on Rails Refactoring (Addison-Wesley Professional Ruby Series) (Paperback)
This book makes a great companion to Martin Fowler's Refactoring book (or the Ruby version of it by Jay Fields). As someone who's still accumulating the theoretical 10,000 hours of experience it takes to master something (Ruby/Rails), it's nice to have guides like Chad and Tammer there to suggest improvements to my technique. Highly recommended for anyone novice or intermediate Rails developer.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


5 of 5 people found the following review helpful
5.0 out of 5 stars A more useful way to teach design patterns, June 15, 2011
Amazon Verified Purchase(What's this?)
This review is from: Rails AntiPatterns: Best Practice Ruby on Rails Refactoring (Addison-Wesley Professional Ruby Series) (Paperback)
All too often, the 'patterns' books only develop a greenfield example the 'right' way. This is hopelessly optimistic, especially if (as is the case for me) you're teaching undergraduates how to use design patterns; they're not going to get it right the first time. So *refactoring* code that has "grown bad" to use a good pattern is a much more frequently needed skill.

There are other books on refactoring for Ruby, like Martin's, but i like that this one focuses on design patterns and specifically on how to leverage Ruby's features to realize the patterns nicely.

My future coverage of design patterns in Berkeley's undergraduate software engineering class will be motivated by the examples in this book.
Help other customers find the most helpful reviews 
Was this review helpful to you? Yes No


Share your thoughts with other customers:
 See all 8 customer reviews...

Online Sample Chapter

Best Practice Ruby on Rails Refactoring: Databases

Sample Pages

Download the sample pages (includes Chapter 9 and Index)

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

AntiPattern: Disappearing Assets   271

AntiPattern: Sluggish SQL   272

AntiPattern: Painful Performance   282

 

Chapter 9: Databases         291

AntiPattern: Messy Migrations   292

AntiPattern: Wet Validations   297

 

Chapter 10: Building for Failure         301

AntiPattern: Continual Catastrophe   302

AntiPattern: Inaudible Failures   306

 

Index          311

 
Best Value

Book + eBook Bundle  $80.98  $48.59

Book Price $35.99
eBook Price $12.60
eBook formats included

Buy

This book includes free shipping!

Buy

Book  $44.99  $35.99

Usually ships in 24 hours.

This book includes free shipping!

Buy

eBook (Watermarked)  $35.99  $28.79

Includes EPUB, MOBI, and PDF
About eBook Formats

This eBook includes the following formats, accessible from your Account page after purchase:

ePubEPUBThe open industry format known for its reflowable content and usability on supported mobile devices.

MOBIMOBIThe eBook format compatible with the Amazon Kindle and Amazon Kindle applications.

Adobe ReaderPDFThe popular standard, used most often with the free Adobe® Reader® software.

This eBook requires no passwords or activation to read. We customize your eBook by discretely watermarking it with your name, making it uniquely yours.

Purchase Reward: One Month Free Subscription
By completing any purchase on InformIT, you become eligible for an unlimited access one-month subscription to Safari Books Online.

Get access to thousands of books and training videos about technology, professional development and digital media from more than 40 leading publishers, including Addison-Wesley, Prentice Hall, Cisco Press, IBM Press, O'Reilly Media, Wrox, Apress, and many more. If you continue your subscription after your 30-day trial, you can receive 30% off a monthly subscription to the Safari Library for up to 12 months. That's a total savings of $199.