Why should I learn patterns?
我为什么要学习模式?
The truth is that you might manage to work as a programmer for many years without knowing about a single pattern. A lot of people do just that. Even in that case, though, you might be implementing some patterns without even knowing it. So why would you spend time learning them?
事实是,你可能在不了解单一模式的情况下设法作为程序员工作多年。很多人就是这样做的。但是,即使在这种情况下,您也可能在不知不觉中实现某些模式。那么,你为什么要花时间学习它们呢?
Design patterns are a toolkit of tried and tested solutions to common problems in software design. Even if you never encounter these problems, knowing patterns is still useful because it teaches you how to solve all sorts of problems using principles of object-oriented design.
设计模式是软件设计中常见问题的久经考验的解决方案工具包。即使你从未遇到过这些问题,了解模式仍然很有用,因为它教会了你如何使用面向对象设计的原则来解决各种问题。Design patterns define a common language that you and your teammates can use to communicate more efficiently. You can say, “Oh, just use a Singleton for that,” and everyone will understand the idea behind your suggestion. No need to explain what a singleton is if you know the pattern and its name.
设计模式定义了一种通用语言,您和您的团队成员可以使用该语言来更有效地进行通信。你可以说,“哦,就用一个单例来做这件事吧”,每个人都会理解你的建议背后的想法。如果您知道模式及其名称,则无需解释什么是单例。