2007年5月28日星期一

Being Studing Design Patterns

  早就买了设计模式的书了,去年看了几个模式,就丢在书柜了,感觉当时自己不适合看那书。前几个月翻了一下 《Head Fisrt Design Partterns》,觉得自己可以开始看了。

  结合GOF的《设计模式:可复用的软件基础》,看了前三份之一的《Design Patterns Explained》,对以前看的几个模式了解更深了。还在当前的项目中小用了一下,感觉还不错。前几天做的东西,需求一直要变,搞得我挺晕的。

  为什么要学设计模式呢(转自《Design Patterns Explained》):
It helps to
  • Reuse existing, high-quality solutions to commonly recurring problems.

  • Establish common terminology to improve communications within teams.

  • Shift the level of thinking to a higher perspective.

  • Decide whether I have the right design, not just one that works.

  • Improve individual learning and team learning.

  • Improve the modifiability of code.

  • Facilitate adoption of improved design alternatives, even when patterns are not used explicitly.

  • Discover alternatives to large inheritance hierarchies.

  在面向对象设计方面,GOF有这么几个建议:
  • Design to interfaces.

  • Favor composition over inheritance.

  • Find what varies and encapsulate it

还有:One place, One rule. 也就说: have only one place where you implement a rule.

还有好多,要好好看......

1 条评论:

匿名 说...

设计模式挺重要的