目錄
我是 xdite,本書是我在 Ruby Conf Taiwan 2011 給的講題:「Essential Rails Design Pattern for Beginners」所整理而成。
在開發 Rails 網站 時,Rails Developer 因為有著來自四面八方的背景,在不懂 Ruby / 不瞭解 Rails Way 的情況下,常常實作出一些詭異的設計,或者是對於某一些功能不知如何下手實作。 本書將整理一些常見的 “AntiPattern”。整理出初學者有可能寫出的爛 code,並一一解釋這樣設計的失當之處。 再補充許多常見的 Rails Design Pattern 以及最佳實務。包括:
分別在 Model / View / Controller 內應該正確的怎樣設計包裝 method,對於網站上一些常見的功能,如何善用 Rails 本身的 built-in feature 實作。提供維護日益龐大的代碼庫之常見整理技巧。
預定於2012年上半年出版。如果您對這本書有任何意見或勘誤指教,歡迎來信和我聯絡。
本書購買連結在 http://rails-101.logdown.com/books/3-essential-rails-pattern 。
售價 $14.99 USD。預售價 $9.99 USD。
字數 : 111514+ now
第一章: 學習寫出好的 Rails code - (100%)
第二章: 基本的 Ruby Style - (100%)
- 縮排慣例
- 命名慣例
- 迴圈慣例
- 括號慣例
- Boolean 慣例
- 邏輯慣例
- 其他慣例
第三章: [基本的 Rails 常識]
- Routing: RESTful
- 熟練 RESTful - (100%)
- RESTful on Rails - (100%)
- More RESTful on Rails - (100%)
- View: Helper - (100%)
- Helper 與 Partial 的不同
- 為什麼在專案中我們要使用內建 Helper 開發?
- 為什麼在專案中我們要撰寫「自用」 Helper?
- [View: Partial]
- [View: yield]
- [View: Builder]
- DB: Migration - (100%)
- Model: scope - (70%)
- [Model: collet]
- [Model: ids]
- Model: counter_cache - (70%)
- [Model: setter/getter]
- [Model: STI]
[Model: Polymorphic Assoiciaion]
[Controller: before_filter]
- Rake - (90%)
- Bundler - (100%)
- Sass/SCSS 與 Compass - (90%)
第四章:診斷你的 Application
General AntiPatterns
- 縮寫 - (70%)
- 不適當的命名 - (80%)
- 條件式的誤用 - (50%)
- LOGIC in View - (20%)
- 在 Controller 裡處理資料- (20%)
- 在 Model 裡寫 view code- (20%)
- Helper Antipatterns- (90%)
- 濫用 ORM 無限串接- (20%)
- 不使用 RESTful- (20%)
- Query in Loop- (20%)
- Reinvent wheels- (10%)
- auto_link
- content_tag
- truncate
- simple_format
- cycle
- localized
- escaple_javascripts
Rails AntiPatterns
View
- 超過 2.5 頁的 View - (50%)
- 同樣用途的 helper 出現第三次 - (50%)
Controller
- 類似的 code 在同一個 controller 出現第3次 - (50%)
- 相同的 method 在不同 controller 出現第二次 - (50%)
- 類似形式的 controller 出現第二次 - (50%)
- 單一 method 超過 15 行 - (50%)
- 儲存之前、儲存之後需要 do something- (100%)
- model callbacks
- Observer
- CRUD-Like Action- (50%)
Model
- Model 超過 2.5 頁- (50%)
- extract to module
- STI / NameSpace
- composed class
- 類似作用與名稱的 Model 超過 2 個- (50%)
- Polymorphic Association
- column 超過 10 個請注意 - (50%)
- Virtual Attribute
- getter / setter
- serializd
- 名稱類似、作用也類似的 method 在同一 class 出現三次以上 - (50%)
- define_method
- method_missing
第五章:實用整理招數
- Model 整理術- (70%)
- model 的排列順序
- annotate
- View 整理術 - (40%)
- template
- partial
- Cell
- Controller 整理術- (50%)
- resources
- namespace
- Helper 整理術 - (50%)
- by controller
- extract common helper to module
- Asset 整理術 - (10%)
- SCSS
- Compass
- Library
第六章:如何用 Gem 整理 Application
- Permission : Cancan - (10%)
- Settings : SettingLogic - (10%)
- Cache: Cells - (10%)
- Expensive Job: Delayed Jobs & Reqsque - (10%)
- Crontab: Whenever - (10%)
- Login Integration : OmniAuth - (0%)
- Deploy: Capistrano & Cape - (0%)