我已经阅读了大约4-5本关于设计模式的书籍,但我仍然觉得我在设计模式方面还没有接近中级水平?
我应该如何学习设计模式?
有关于设计模式的好书吗?
我知道这只会来的经验,但必须有一些方法来掌握这些?
我已经阅读了大约4-5本关于设计模式的书籍,但我仍然觉得我在设计模式方面还没有接近中级水平?
我应该如何学习设计模式?
有关于设计模式的好书吗?
我知道这只会来的经验,但必须有一些方法来掌握这些?
当前回答
我读了三本书,仍然不能很好地理解模式,直到我读了OReilly的Head First Design patterns。这本书让我大开眼界,解释得很清楚。
其他回答
I would think it is also difficult to study design patterns. You have to know more about OOP and some experiences with medium to big application development. For me, I study as a group of developers to make discussion. We follow A Learning Guide To Design Patterns that they have completed the patterns study. There are C# and JavaScript developers join together. It is fancy thing for me is the C# developer write codes in JavaScript and the JavaScript developer do the same thing for C# codes. After I leave a meeting I also research and read a few books at home to review. The better way to understand more and remember in my mind is to do blogging with examples in both C# and JavaScript in here http://tech.wowkhmer.com/category/Design-Patterns.aspx.
我建议首先在去了解每个设计模式之前请先了解模式的名称。此外,如果有人知道这个概念,请解释并给出一个例子,不仅是编程,而且是阅读世界。
例如:
工厂方法:
阅读世界:我只要给钱5美元、10美元或20美元,它就会生产出披萨,而不知道它是如何生产的,我只会得到一个小的、中等的或大的披萨,这取决于我投入的钱,这样我就可以吃或做任何事情。
编程:客户端只需将参数值$5,$10或$20传递给factory方法,它将返回Pizza对象。因此客户端可以使用该对象,而不知道它是如何处理的。
我不确定这能帮到你。这取决于与会者的知识水平。
有很多很好的例子。我想补充一点:
误用。您不需要故意这样做,当您尝试在初始设计模式匹配中应用它们时,就会发生这种情况。在此期间,您将看到的每个问题似乎都恰好符合一种设计模式。通常,由于某些原因,所有问题似乎都符合相同的设计模式(Singelton是主要的候选)。
你应用这个模式就会很好。几个月后,您将需要更改代码中的某些内容,并发现使用特定的模式并不明智,因为您将自己编码到一个角落,您需要再次重构。
当然,这并不是一个真正的“做了就会在21天内学会”的答案,但以我的经验来看,这是最有可能让你对问题有一个很好的洞察的答案。
在我看来,阅读设计模式,练习编码的概念并没有真正的帮助。当你读这些书的时候。寻找特定设计模式解决的基本问题,从创建模式开始是最好的选择。2. 我相信你过去写过代码,分析一下你是否遇到了设计模式旨在提供解决方案的相同问题。3.尝试重新设计/重构代码,或者重新开始。
关于资源,你可以查看这些
www.dofactory.com 设计模式:可重用面向对象软件的元素(Addison-Wesley专业计算系列),作者:Erich Gamma、Richard Helm、Ralph Johnson和John M. Vlissides Martin Fowler的《企业应用程序体系结构模式》
1是快速入门,2是深入学习。第3节将解释或应该让你认为你在第2节中学到的东西适用于企业软件。
我的2美分…
我认为您需要检查一些您作为开发人员遇到过的问题,当您因为另一个设计更改而不得不第十次修改代码时,您会感到非常紧张。你可能有一个项目清单,你觉得有很多返工和痛苦。
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.
Derek Banas在youtube上制作了我非常喜欢的图案设计教程:
http://www.youtube.com/playlist?list=PLF206E906175C7E07
他们可能在时间上有点短,但他的时机和呈现方式使他们非常愉快地学习。