问题描述
我已经阅读了有关设计模式的4-5本书,但我仍然觉得自己在设计模式方面越来越接近中级水平吗?
我应该如何学习设计模式?
有什么好书用于设计模式吗?
我知道这只会有经验,但是必须有一些方法来掌握这些?
推荐答案
最好的方法是开始与它们进行编码.设计模式是一个很棒的概念,很难仅阅读它们.采取一些您在网上找到的示例实现并围绕它们堆积.
一个很棒的资源是数据&对象工厂页面.他们介绍了模式,并为您提供概念和现实世界的例子.他们的参考材料也很棒.
其他推荐答案
我读了三本书,直到我阅读首先设计模式 by Oreilly.这本书睁开了我的眼睛,真的很好地解释了.
https://encrypted-tbn0.gstatic.com/images?q = = tbn:ast9gcr9ohznke8bwdqrgyaeeaeeeaeeeaeewkdvjp1akc8opx3wazg-jdq6bdbc9i_ alt alt alt
其他推荐答案
我的两分钱都适合这样的旧问题
有些人已经提到,练习和重构.我相信了解模式的正确顺序是:
- 学习测试驱动开发(TDD)
- 学习重构
- 学习模式
大多数人忽略1,许多人认为他们可以做2,几乎每个人都直奔3.
对我来说,提高我的软件技能的关键是学习TDD.这可能是长时间的痛苦和缓慢编码的时间,但是首先编写测试肯定会让您对代码进行很多思考.如果一堂课需要太多的样板或很容易破裂,您就会开始注意到不良气味很快
TDD的主要好处是,您失去了对重构代码的恐惧,并强迫您写高度独立和凝聚力的课程.没有一套好的测试,触摸没有破裂的东西就太痛苦了.有了安全网,您将真正冒险对您的代码进行彻底的更改.那是您真正可以从实践中学习的时刻.
现在是您必须阅读有关模式的书籍的地步,我认为,这完全浪费了时间.在注意到我做了类似的事情之后,我只能很好地理解模式,或者可以将其应用于现有代码.没有安全测试或重构习惯,我会等到一个新项目.在新项目中使用模式的问题是,您看不到它们如何影响或更改工作代码.一旦我将代码重构为其中一个,我才理解一种软件模式,当我在代码中介绍一个新鲜时,我从来没有.
.问题描述
I have read around 4-5 books on design patterns, but still I don't feel I have come closer to intermediate level in design patterns?
How should I go studying design patterns?
Is there any good book for design patterns?
I know this will come only with experience but there must be some way to master these?
推荐答案
The best way is to begin coding with them. Design patterns are a great concept that are hard to apply from just reading about them. Take some sample implementations that you find online and build up around them.
A great resource is the Data & Object Factory page. They go over the patterns, and give you both conceptual and real world examples. Their reference material is great, too.
其他推荐答案
I read three books and still did not understand patterns very well until I read Head First Design Patterns by OReilly. This book opened my eyes and really explained well.
其他推荐答案
My two cents for such and old question
Some people already mentioned, practice and refactoring. I believe the right order to learn about patterns is this:
- Learn Test Driven Development (TDD)
- Learn refactoring
- Learn patterns
Most people ignore 1, many believe they can do 2, and almost everybody goes straight for 3.
For me the key to improve my software skills was learning TDD. It might be a long time of painful and slow coding, but writing your tests first certainly makes you think a lot about your code. If a class needs too much boilerplate or breaks easily you start noticing bad smells quite fast
The main benefit of TDD is that you lose your fear of refactoring your code and force you to write classes that are highly independent and cohesive. Without a good set of tests, it is just too painful to touch something that is not broken. With safety net you will really adventure into drastic changes to your code. That is the moment when you can really start learning from practice.
Now comes the point where you must read books about patterns, and to my opinion, it is a complete waste of time trying too hard. I only understood patterns really well after noticing I did something similar, or I could apply that to existing code. Without the safety tests, or habits of refactoring, I would have waited until a new project. The problem of using patterns in a fresh project is that you do not see how they impact or change a working code. I only understood a software pattern once I refactored my code into one of them, never when I introduced one fresh in my code.