over 10 years ago

Summary

總結以上 18 個設計手法,看似複雜,其實原則不外乎:

  • Always assume things need to be decorated (永遠假設東西必須要被裝飾)
  • Extract logic into methods / classes ( 將邏輯封裝成 method 或者 class )
  • Avoid perform query in view/helper ( 盡量避免在 view/helper 裡面進行資料查詢 )
  • When things get complicated, build a new control center (當事情變得複雜,不要拘泥於舊的手段,找一個新的中心重新整理控制)

掌握這些原則,就可以儘量把 View 整理的乾乾淨淨。

reference

在撰寫以上內容時,我的參考內容有:

歡迎各位留言指教。


Maintainable Rails View 系列文目錄

← Maintainable Rails View (5) Maintainable Rails View is now a Book →
 
comments powered by Disqus