何时使用哪种设计模式? [英] When to use which design pattern?
问题描述
我非常喜欢设计模式,但是我很难看清我何时可以申请。我已经阅读了很多设计模式被解释的网站。我明白了他们中的大多数,但是我觉得很难在我自己的情况下认识到一种模式。
I like design patterns very much, but I find it difficult to see when I can apply one. I have read a lot of websites where design patterns are explained. I do understand the most of them, but I find it difficult to recognize a pattern in my own situations.
所以这就是为什么我问这个问题。在使用哪种设计模式时,是否有任何指引/闹钟。
So, that is why I ask this question. Are there any guidelines / alarm bells when to use which design pattern.
例如,如果您正在执行switch语句来确定需要创建哪个对象,那么您可能想要使用工厂的设计模式。因此,这种情况下的switch语句是使用Factory模式的闹钟。
For example, if you are doing a switch statement to determine which object you need to create, you probably want to use the factory design pattern. So the switch statement in this case is a 'alarm bell' to use the Factory pattern.
那么,你知道更多的闹钟来确定设计模式吗?
So, do you know more 'alarm bells' to determine a design pattern?
推荐答案
对于初学者只要看一看这个页面:
http://codebetter.com/jeremymiller/2006/04/11/six-design-patterns -to-start-with /
For starters just take a peek at this page: http://codebetter.com/jeremymiller/2006/04/11/six-design-patterns-to-start-with/
虽然Jeremy在这里处理了一些模式,但您必须阅读这些文章,然后按照以下步骤操作:
http://codebetter.com/jeremymiller/ 2005/09/01 / learn-about-design-patterns /
While Jeremy here deals with a few set of patterns, you must read these articles and then follow it up with this: http://codebetter.com/jeremymiller/2005/09/01/learning-about-design-patterns/
还可以使用本文的引用(特别是Eric Gamma的面试),你应该组。
Also use the references on this article(especially Eric Gamma's interview) and you should be set.
这篇关于何时使用哪种设计模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!