Compose Method [Beck, SBPP]
You can't rapidly understand a method's logic.
Transform the logic into a small number of intention-revealing steps at the same level of detail
以下 by [Kerievsky, Refactoring to Patterns]
Motivation:
這個 pattern 看起來很簡單, 好像每個 programmer 都應該這樣寫 code, 但是如果你仔細檢視一下自己寫的 code, 你會發現, 應該大部份的 code 都沒有做到這個 pattern 的要求. Compose Method 簡單來說, 就是 method 裡面 compose 其他的東西, 都必須要在同個 detail 等級之下(Mechanics 第五點).
2011年3月23日 星期三
2011年3月20日 星期日
Smell good?
最近為了國人的生活品質與身體健康, 義無返顧的投入了清潔大隊, 在經歷了尖山火池, 天崩地裂, 毒氣瀰漫, 輻射籠罩的考驗中, 能活著回來真的是菩薩保佑, 祖上積福~ 在身體還未被恐怖的碘, 鈽的放射性同位素給侵蝕殆盡前, 趕快將所見所聞來跟大家分享~
在此先端出德高望重的貝克大師[Beck Kent]的武林秘笈心法:
扛布絲埋圾袋 [Compose Method]
在此先端出德高望重的貝克大師[Beck Kent]的武林秘笈心法:
扛布絲埋圾袋 [Compose Method]
Labels:
design pattern,
Solid Programming
2009年12月11日 星期五
Bridge Patthern
昨天真是愉快(打混)的一天,因為欠上篇提到coding convention與link裡的Herder files dependencies讓我想起之前effective c++報告過的item 31 Minimize compilation dependencies between files。在大家討論的過程中,forward declaration 的精神相信大家都透過hsu的 abow-stara類別圖更了解了,現在來點實用的吧! Bridge Pattern。我小改了以前item31的sample(因為貼code篇幅還有天生的惰性,在Person端的implement有偷懶),總之,review以前的code再擴充些亂七八糟的想法真是太有趣了。
Labels:
C++,
design pattern
訂閱:
文章 (Atom)