- Started reading:
- 24th January 2011
- Finished reading:
- 9th February 2011
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.
I have mixed feelings about this book. First few chapters (about models, controllers, views, and web services, testing) were pretty neat: useful precise antipatterns definitions along with their solutions. Some of them are pretty obvious, but anyways I was enjoying the reading. Things changed at the end of the book. Chapters about databases and scaling are… kinda disturbing. Does the author believe that
@users = @account.users.order('LCASE(name)').limit(5)
is the right way to do such a things? Does he really recommends the following query to improve performance and fix scalability issues?
SELECT DISTINCT users.* FROM users
INNER JOIN comments
ON comments.user_id = users.id
INNER JOIN users users_comments
ON users_comments.id = comments.user_id
INNER JOIN articles
ON articles.id = comments.article_id
INNER JOIN comments comments_articles
ON comments_articles.article_id = articles.id
WHERE (articles.id IN (1) AND users.id != 1)
If you want to kill a few hours, you may check it out, but I will not recommend this book to my friends.