我已经阅读了大约4-5本关于设计模式的书籍,但我仍然觉得我在设计模式方面还没有接近中级水平?
我应该如何学习设计模式?
有关于设计模式的好书吗?
我知道这只会来的经验,但必须有一些方法来掌握这些?
我已经阅读了大约4-5本关于设计模式的书籍,但我仍然觉得我在设计模式方面还没有接近中级水平?
我应该如何学习设计模式?
有关于设计模式的好书吗?
我知道这只会来的经验,但必须有一些方法来掌握这些?
当前回答
你试过《四人帮》这本书吗?
设计模式:可重用面向对象软件的元素
其他回答
我推荐HeadFirst DesignPattern。阅读书本是不够的,在吸收了这些概念之后,你需要为你脑海中出现的许多问题找到答案,并试图找出这些模式在现实生活中的应用。我也在做同样的事情,开始问问题,即使这些问题看起来很傻。
我认为您需要检查一些您作为开发人员遇到过的问题,当您因为另一个设计更改而不得不第十次修改代码时,您会感到非常紧张。你可能有一个项目清单,你觉得有很多返工和痛苦。
From that list you can derive the scenarios that the Design Patterns intend to solve. Has there been a time where you needed to perform the same series of actions on different sets of data? Will you need to be able to future capability to an application but want to avoid reworking all your logic for existing classes? Start with those scenarios and return to the catalog of patterns and their respective problems they are supposed to solve. You are likely to see some matches between the GoF and your library of projects.
The way I learned design patterns is by writing lots of really terrible software. When I was about 12, I have no idea what was good or bad. I just wrote piles of spaghetti code. Over the next 10 years or so, I learned from my mistakes. I discovered what worked and what didn't. I independently invented most of the common design patterns, so when I first heard what design patterns were, I was very excited to learn about them, then very disappointed that it was just a collection of names for things that I already knew intuitively. (that joke about teaching yourself C++ in 10 years isn't actually a joke)
这个故事的寓意是:编写大量的代码。就像别人说的,练习,练习,再练习。我认为,在您了解当前的设计为什么不好并寻找更好的方法之前,您不会很好地了解在哪里应用各种设计模式。设计模式书应该为您提供完善的解决方案和与其他开发人员讨论的通用术语,而不是对您不理解的问题的粘贴解决方案。
Derek Banas在youtube上制作了我非常喜欢的图案设计教程:
http://www.youtube.com/playlist?list=PLF206E906175C7E07
他们可能在时间上有点短,但他的时机和呈现方式使他们非常愉快地学习。
我的建议是组合实现其中的一些,并分析它们的一些实现。例如,在. net中,如果您查看数据适配器,就会发现有一些适配器模式的使用,如果稍微深入研究框架,还会发现其他一些适配器模式。