如何研究设计模式?[英] How to study design patterns?











我读了三本书,直到我阅读首先设计模式 by Oreilly.这本书睁开了我的眼睛,真的很好地解释了.

https://encrypted-tbn0.gstatic.com/images?q = = tbn:ast9gcr9ohznke8bwdqrgyaeeaeeeaeeeaeewkdvjp1akc8opx3wazg-jdq6bdbc9i_ alt alt alt




  1. 学习测试驱动开发(TDD)
  2. 学习重构
  3. 学习模式








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.

alt text


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:

  1. Learn Test Driven Development (TDD)
  2. Learn refactoring
  3. 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.