结构与行为设计模式

structural vs behavioural design patterns

刚开始看设计模式,有一些基本的疑惑,看了很多文章也不清楚。有人可以解释一下吗?我在这里看到很多类似的帖子,但都不是很清楚。

  1. 他们是如何划分为结构和行为模式的?

  2. 有什么好书可以看吗?现在我在看Head first design patterns

  3. 记住所有这些模式并加以应用的简单方法是什么?我想记住每个模式的 UML 图和概念。你建议任何其他方式吗?

  1. How did they segregate in to structural and behavioural patterns?

来自 Gof 书

"Structural patterns are concerned with how classes and objects are composed to form larger structures. "

一些结构模式:

  • 适配器
  • 装饰器
  • 立面
  • 代理
  • 享元

等等

"Behavior patterns are concerted with algorithms and the assignment of responsibilities between objects. Behavioral patterns describe not just the patterns of objects or classes but also the patterns of communication between them."

一些行为模式:

  • 责任链
  • 命令
  • 迭代器
  • 调解员
  • 观察者
  • 访客

等等

  1. Is there any good book to follow?Now I am following Head first design patterns.

这个问题超出了 SO 的范围,因为我们真的不应该推荐书籍。

  1. What is the easy way to remember all these patterns and apply? I thought of remembering UML diagram and concept for each pattern. Do you suggest any other way?

设计模式的 UML 图令人困惑,因为多个模式具有足够相同或相似的图,您无法将它们区分开来。不幸的是,最简单的方法是只使用它们,直到知道如何使用它们。并在手边放一本设计模式书,为那些你不记得的较少使用的模式寻找动机。