我已经阅读了大约4-5本关于设计模式的书籍,但我仍然觉得我在设计模式方面还没有接近中级水平?
我应该如何学习设计模式?
有关于设计模式的好书吗?
我知道这只会来的经验,但必须有一些方法来掌握这些?
我已经阅读了大约4-5本关于设计模式的书籍,但我仍然觉得我在设计模式方面还没有接近中级水平?
我应该如何学习设计模式?
有关于设计模式的好书吗?
我知道这只会来的经验,但必须有一些方法来掌握这些?
当前回答
我领导了一些设计模式讨论小组(我们的网站),并阅读了5或6本模式书籍。我建议从《头部优先设计模式》一书开始,参加或发起一个讨论小组。《Head First》一开始可能看起来有点像Hasboro,但大多数人在读了一两章后就喜欢上了它。
Use the outstanding resource - Joshua Kereivisky's A Learning Guide to Design Patterns for the pattern ordering and to help your discussion group. Out of experience the one change I suggest to the ordering is to put Strategy first. Most of today's developers have experienced some good or bad incarnation of a Factory, so starting with Factory can lead to a lot of conversation and confusion about the pattern.This tends to take focus off how to study and learn patterns which is pretty essential at that first meeting.
其他回答
你试过《四人帮》这本书吗?
设计模式:可重用面向对象软件的元素
有很多很好的例子。我想补充一点:
误用。您不需要故意这样做,当您尝试在初始设计模式匹配中应用它们时,就会发生这种情况。在此期间,您将看到的每个问题似乎都恰好符合一种设计模式。通常,由于某些原因,所有问题似乎都符合相同的设计模式(Singelton是主要的候选)。
你应用这个模式就会很好。几个月后,您将需要更改代码中的某些内容,并发现使用特定的模式并不明智,因为您将自己编码到一个角落,您需要再次重构。
当然,这并不是一个真正的“做了就会在21天内学会”的答案,但以我的经验来看,这是最有可能让你对问题有一个很好的洞察的答案。
问自己这些问题:
他们做什么?
它们是如何耦合的?
什么时候使用它们?
什么时候不应该使用它们?
什么缺失的语言特征会让它们消失?
使用它会导致什么技术债务?
有没有更简单的方法来完成工作?
我领导了一些设计模式讨论小组(我们的网站),并阅读了5或6本模式书籍。我建议从《头部优先设计模式》一书开始,参加或发起一个讨论小组。《Head First》一开始可能看起来有点像Hasboro,但大多数人在读了一两章后就喜欢上了它。
Use the outstanding resource - Joshua Kereivisky's A Learning Guide to Design Patterns for the pattern ordering and to help your discussion group. Out of experience the one change I suggest to the ordering is to put Strategy first. Most of today's developers have experienced some good or bad incarnation of a Factory, so starting with Factory can lead to a lot of conversation and confusion about the pattern.This tends to take focus off how to study and learn patterns which is pretty essential at that first meeting.
对于书籍,我推荐《设计模式解释》和《头部优先设计模式》。要真正了解这些模式,您应该查看现有的代码。寻找你已经在使用的模式。查看代码气味和可以解决它们的模式。