-
enterprise_rails.pdf下载
资源介绍
Table of Contents
Preface ..................................................................... xi
1. The Big Picture ......................................................... 1
What Is Enterprise?
1
Growing Slowly
3
Understanding All the Pieces
5
Persistence Layer
5
Application Layer
8
Caching Layer
11
Messaging System
16
Web Server
16
Firewall
16
2. Organizing with Plugins ................................................ 19
Benefits
20
Writing Your Own Plugins
21
Core Enhancements
22
Custom Extensions
26
Deployment
30
svn:externals
30
3. Organizing with Modules ................................................ 31
Files and Directories
32
Module Boundaries for Namespacing
33
ActiveRecord Associations Between Modules
34
Reciprocal Relationships
35
Modules Presage Services
36
Ensuring Proper Load Order
38
Exercises
39
Refactor Steps
39
High-Level Module Refactor
39
Detangling Utility Methods
40
v
4. Database As a Fortress .................................................. 41
Your Database Is an Application, Too
42
“One Framework to Rule Them All”
42
“No One in My Company Will Ever Write a Bug”
42
“This Rails Application Is the Only Application on Earth”
43
Sit Atop the Shoulders of Giants
43
Choosing the Right RDBMS
44
A Note on Migrations
44
Dispelling Myths
46
Operations and Reporting
47
5. Building a Solid Data Model ............................................. 51
Theatre Tickets
51
Starting Simple
52
Constraints
54
Mythbusting
63
Referential Integrity
64
Intro to Indexing
70
6. Refactoring to Third Normal Form ........................................ 73
Third Normal Form
73
Timing Is Key
77
Refactoring: Inheritance and Mixins
78
Exercises
82
Refactor Steps
82
7. Domain Data .......................................................... 85
Dealing with Zip Codes
87
Strategy Pattern with Domain Tables
89
Refactor from Day One
93
8. Composite Keys and Domain Key/Normal Form ............................. 95
Why Composite Natural Keys Matter
97
Spotting Composite Keys
99
Atop the Shoulders of…
101
Migrating to Domain Key/Normal Form
102
Using Composite Keys in Rails
105
Deferrable Foreign Key Constraints
109
Understanding the Trade-offs
111
Exercises
113
Refactor Steps
113
Single Column Refactor
114
vi|Table of Contents
Multiple Column Refactor
115
9. Guaranteeing Complex Relationships with Triggers ........................ 117
Constraint Checking with Triggers
117
Anatomy of a PL/pgSQL Function
121
10. Multiple Table Inheritance ............................................. 127
The Problem
127
What Is Polymorphism?
129
Inheritance and Persistence
131
Single Table Inheritance
132
Multiple Table Inheritance
133
XOR on Columns
135
Elegant MTI in Rails
137
Factory Classes
143
Exercises
144
Refactor Steps
145
Refactoring STI
145
Refactoring: polymorphic => true
145
11. View-Backed Models .................................................. 147
Database Views
148
Creating a View
149
Basing a Model on a View
149
Considerations
150
Insert, Update, Delete
151
References and Constraints
152
Indexing
153
Exercises
153
Refactor Steps
154
12. Materialized Views .................................................... 155
Materialized View Principles
156
A View to Materialize
157
Getting into Form
158
The Target Table
160
Refresh and Invalidation Functions
161
Time Dependency
163
Who Pays the Price?
165
Triggered Refreshes and Invalidations
168
Movie Showtimes
169
Hiding the Implementation with the Reconciler View
174
Periodic Refreshes
177
Table of Contents|vii
Cache Indexes
178
Results
179
Cascading Caches
180
Exercises
180
13. SOA Primer .......................................................... 183
What Is SOA?
183
Why SOA?
186
Shared Resources
187
Reduce Database Load
190
Scalability II: Caching Is Tricky
196
Reduce Local Complexity
197
In Summary
200
Exercises
200
14. SOA Considerations ................................................... 201
Service Considerations
201
Implementation Details Are Hidden
202
API Is Accessible
204
API Design Best Practices
205
Send Everything You Need
205
Limit Round Trips
207
Look for Opportunities for Parallelization
209
Send as Little as Possible
210
REST Versus XML-RPC Versus SOAP
212
XML-RPC
212
SOAP
214
15. An XML-RPC Service ................................................... 217
ActionWebService and Rails 2.0
217
Creating an Abstraction Barrier
218
ActiveRecord As the Physical Model Layer
218
The Object Model Layer
220
Defining the API
225
More Testing
230
The Client Plugin
232
Shared Code
234
The Client Singleton
234
Integration Testing
236
16. Refactoring to Services ................................................ 239
An Orders Service
239
Integrating with the MoviesService
251
viii|Table of Contents
Other Considerations
253
MoviesService Object Model
254
Putting It All Together
265
17. REST Primer .......................................................... 267
REST Basics
267
Resources and Verbs
267
Hardware Is Part of the Application
269
Mapping REST to SOA
270
Mapping to CRUD
270
Different Clients, One Interface
272
HTTP+POX
274
Defining a Service Contract
274
REST Clients in Ruby
276
The Way the Web Was Meant to Be Used
277
18. A RESTful Web Service ................................................. 279
Scoping the Problem
279
Tools
281
MoviesWebService
284
Resources Server Implementation
285
Actions Server Implementation
288
A Client Implementation
289
19. Caching End to End .................................................... 295
Data Layer Caching, Revisited
296
The Snapshot
296
The Refresh Function
297
Invalidation Triggers
297
Indexing
298
Logical Model Caching
298
Considerations
305
Avoiding Rebuilding with Stale Data
308
Cache Indexes
312
Other Caching
313
Query Plan Caching
313
Database Query Caching
314
Rails Query Caching
315
Fragment, Action, and Page Caching
316
Index ..................................................................... 319
- 上一篇: PHP和MySQL Web开发第四版源代码(完整版
- 下一篇: 高速数字系统设计+互连理论和设计