Feature toggle - configuration over code
很久之前的 Post [Feature toggle (a.k.a Feature Flags) in Ruby and gems to use](https://waynechu.cc/posts/441-feature-toggle-a-k-a-feature-fla...
How DHH write RESTful controller
常常要貼這個連結給別人但每次都忘記這篇的連結在哪,紀錄一下以後好搜尋 https://gist.github.com/dhh/10022098
What’s Object Marshalling?
## What’s Object Marshalling? Object Marshalling 將資料轉換,用在不同程式間傳輸,就稱為 Object Marshalling (序列化) 例如 Sidekiq 會把 Object 變成 JSON 存進 ...
用 Ruby proc 做 success and error handler, like JS Promise
```rb # A base class for all classes implement calls to API. class ApiCall attr_reader :params def self.call(params) new(param...
一篇講 OO cohesion 和 coupling 簡單易懂的文章
一直想找個好方式跟同事解釋怎麼 decoupling 和 design better code,這篇文章涵蓋了最重要的兩個概念而且用很簡單易懂的 code 解釋了,很不錯。 cohesion: class 裡的 methods 是不是 share 一樣的 contex...
kickstarter 的 event sourcing approach
也解釋了一些 event sourcing 相關的東西,還不錯的深入淺出好文,而且還有 gif 圖加分XD 這張就很棒的解釋了他們所謂的 Aggregation (綠色, state), Reactor (黃色), Calculator (藍色箭頭), Event (藍色...
rails before_actoin design pattern - Aspect-oriented_programming (AOP)
想要對 ruby class 實作 before_action ,查到 https://stackoverflow.com/questions/23444964/is-it-possible-to-do-a-before-action-in-ruby-like-in-ra...
rails singleton class
```rb # File activesupport/lib/active_support/core_ext/object/singleton_class.rb, line 3 def singleton_class class << self ...
Form object pattern
優點: 1. 把讓 controller 和 view 的邏輯拆開,讓 form object 負責,符合 single responsibility principle 2. 如果 include active_record 可以享用 validations, err...
Null object pattern
在需要 check object 是否存在的時候使用 null object pattern,如果 object 不存在就用 null object,null object 提供跟原本 object 很像的 API 接口,並預設這些 API 的行為,讓程式可以安心的使用這...
非常詳細且很棒的 hypermedia api 介紹
讓 client side 知道下一步做什麼,進而可以寫出像 call method 一樣的 client helper。 https://robots.thoughtbot.com/writing-a-hypermedia-api-client-in-ruby
OOP - SRP(Single Responsibility Principle)單一責任原則
『你只有一個理由需要更改這個class,如果有一個以上的理由就表示:這個class負責超過一個以上的責任。』 http://ithelp.ithome.com.tw/articles/10100557
OOP - Dependency-Inversion Principle
重點:program to an interface, not an implementation 原本上層的類別會依賴下層的類別,就如同要蓋二樓就必須蓋好一樓 但 Dependency-Inversion Principle 的意思就是應該要讓上層和下層都依賴於抽象層...
OOP - Law of Demeter 最小知識原則
意思就是假設 A 要問 B 一個問題,但是 B 要問 C 才能知道答案,那麼 A 應該只需要問 B 就好,A 不需要知道 B 還需要問 C,對 A 來說問 B 就能知道答案了 範例 A.askB #=> Answer 違反此原則的範例: A.askB.askC #...
OOP - interface segregation principle ISP 介面分離原則
用戶不應該被迫相依於他們用不到的函示 如果有用不到的函示,應該做成不同的 interface 或是 protocal 有要用到再裝上去就好 * https://danielkjchen.wordpress.com/2016/02/05/%E7%89%A9%E4%BB%B...
OOP - LSP(Liskov Substitution Principle)Liskov替換原則
Liskov替換原則的定義是:『子類別必須能夠替代基礎類別』 不要繼承不必要的遺產,沒用到而去繼承反而是種累贅甚至會搞壞了整個系統也不一定。 http://ithelp.ithome.com.tw/articles/10100827