What does it take to develop an enterprise application with Rails? Enterprise Rails introduces several time-tested software engineering principles to prepare you for the challenge of building a high-performance, scalable website with global reach. You'll learn how to design a solid architecture that ties the many parts of an enterprise website together, including the database, your servers and clients, and other services as well.
Many Rails developers think that planning for scale is unnecessary. But there's nothing worse than an application that fails because it can't handle sudden success. Throughout this book, you'll work on an example enterprise project to learn first-hand what's involved in architecting serious web applications.
With this book, you will:
Tour an ideal enterprise systems layout: how Rails fits in, and which elements don't rely on Rails
Learn to structure a Rails 2.0 application for complex websites
Discover how plugins can support reusable code and improve application clarity
Build a solid data model -- a fortress -- that protects your data from corruption
Base an ActiveRecord model on a database view, and build support for multiple table inheritance
Explore service-oriented architecture and web services with XML-RPC and REST
See how caching can be a dependable way to improve performance
Building for scale requires more work up front, but you'll have a flexible website that can be extended easily when your needs change. Enterprise Rails teaches you how to architect scalable Rails applications from the ground up.
"Enterprise Rails is indispensable for anyone planning to build enterprise web services. It's one thing to get your service off the ground with a framework like Rails, but quite another to construct a system that will hold up at enterprise scale. The secret is to make good architectural choices from the beginning. Chak shows you how to make those choices. Ignore his advice at your peril."-- Hal Abelson, Prof. of Computer Science and Engineering, MIT
Chapter 1 The Big Picture
What Is Enterprise?
Growing Slowly
Understanding All the Pieces
Chapter 2 Organizing with Plugins
Benefits
Writing Your Own Plugins
Deployment
Chapter 3 Organizing with Modules
Files and Directories
Module Boundaries for Namespacing
Exercises
Refactor Steps
Chapter 4 Database As a Fortress
Your Database Is an Application, Too
Sit Atop the Shoulders of Giants
Operations and Reporting
Chapter 5 Building a Solid Data Model
Theatre Tickets
Chapter 6 Refactoring to Third Normal Form
Third Normal Form
Refactoring: Inheritance and Mixins
Exercises
Refactor Steps
Chapter 7 Domain Data
Dealing with Zip Codes
Strategy Pattern with Domain Tables
Refactor from Day One
Chapter 8 Composite Keys and Domain Key/Normal Form
Why Composite Natural Keys Matter
Atop the Shoulders of…
Exercises
Refactor Steps
Chapter 9 Guaranteeing Complex Relationships with Triggers
Constraint Checking with Triggers
Chapter 10 Multiple Table Inheritance
The Problem
What Is Polymorphism?
Inheritance and Persistence
Factory Classes
Exercises
Refactor Steps
Chapter 11 View-Backed Models
Database Views
Basing a Model on a View
Considerations
Exercises
Refactor Steps
Chapter 12 Materialized Views
Materialized View Principles
A View to Materialize
The Target Table
Refresh and Invalidation Functions
Triggered Refreshes and Invalidations
Hiding the Implementation with the Reconciler View
Dan Chak's varied education in real-world web architecture gives him a unique perspective on the challenges of building rock-solid web applications. Dan has worked at Amazon.com, the world's biggest online retail store, where seemingly small technology problems become big ones due to enormous scale. Dan also directed software development at CourseAdvisor Inc., a Ruby on Rails startup company. A nearly instant success, CourseAdvisor was acquired by the Washington Post Company in October 2007. You can hear his thoughts on his blog at http://blog.chak.org.
Dan Chak is obviously one smart guy and this book provides a lot of information not found in any other Rails books.
I have neither the advantage nor experience of working on a large, complex site like Amazon (where Dan worked), so for all I know maybe all of his ideas border on necessity for a site of that complexity. But there does seem to be a lot of straying from the normal philosophies espoused in virtually every other Rails book.
For example, he eschews migrations and instead does all schema manipulation via SQL DDL statements. And choosing PostgreSQL over MySQL means that on more than one occasion MySQL users are left trying to figure out how to accomplish what he has just covered.
None of which is bad; heck, Rails is Latin for "opinionated", right? But if you're in a fairly small shop working on non-Amazon-size websites (which most of them are), I question how many of these fairly complex strategies will be implemented given the perpetual "behind schedule" state we all seem to be in most of the time, not to mention the pressures of "getting something out the door" as soon as possible.
Regarding this issue, I think he himself put it best during his discussion of REST vs. XML-RPC vs. SOAP: "... we must remind ourselves that in the enterprise practicality is at least as important as purity." (Ada, anyone?)
While we all know that "pay me now or pay me later" and "an ounce of prevention is worth a pound of cure" are absolute truths, the real world often dictates we ditch these proverbs.
Regardless, I think this book is a must-read for serious Rails developers. Dan raises a heckuva lot of good points that you won't find anywhere else.