【翻译】设计模式学习系列1---【Design Patterns Simplified: Part 1【设计模式简述:第一部分】】
Design Patterns Simplified: Part 1【设计模式简述:第一部分】
Design patterns are an important consideration when designing or developing any software systems or solutions. There is so much buzz around patterns. At the same time, we often get confused about their use. Basically we get questions like the following:
在设计或者开发任何软件解决方案的时候,设计模式都是一个重要的考虑因素。有这么多声音都围绕着设计模式,我们通常就会很疑惑关于设计模式的使用。基本上,我们的问题有下面这些:
- What design patterns are【什么是设计模式】
- Why to use them【为什么要使用设计模式】
- When to use them【什么时候使用设计模式】
- How many patterns we have【总共有多少设计模式】
In the first part of the series around design patterns, we will try to discuss and answer these questions.
What design patterns are【什么是设计模式】
Design patterns are basically proven solutions to common design problems. They can also be defined as recommended practices to solve any recurring problem in application design.
设计模式是常见的设计问题的解决方案。它们同样可以作为程序设计过程中反复出现的问题的解决方案。
Please be clear that, design patterns are not ready-to-use code that can be used directly, instead they present approaches or recommendations to solve daily design challenges.
这里要说清楚的是,设计模式不是现成的代码,可以直接使用,相反,对于日常设计中出现的挑战, 设计模式是用来提供解决方法或者可行性建议的。
Why to use them【为什么要使用设计模式】
The reason for usign them is simple. Why re-invent the wheel, when we have workable, tested and well documented solutions for a set of common recurring problems?
使用设计模式的原因很简单。为什么,要重复造轮子?对于一系列反复出现的问题,我们是否有可行的,容易测试的,并且有提供文档形式的解决方案么?
We should use design patterns (when required) to design and develop reusable and scalable components that in turn helps the development team to finish the development activities in due time while attaining high quality.
在需要的时候, 我们应该使用设计模式,来设计和开发可重用和可扩展的组件,从而帮助开发团队在规定的时间内,高效有质量地完成开发任务。
Designing an application in a standard or tested fashion also helps other developers and code reviewers to understand the written code easily.
以一个标准设计应用程序,同样可以帮助其他的开发者和代码Review人员更好的测试并理解代码是怎么写的。
When to use them【什么时候使用设计模式】
This is a very pertinent issue and we should be well aware of their usefulness. Using design patterns without evaluating them properly can make the design unnecessarily complex.
这是一个非常中肯的问题,我们应该清楚设计模式的适用性。使用设计模式的时候,没有很好的评估,将会使得设计变得不必要的复杂。
There could be instances when you might not need them at all and you can simply live with basic OOP design principles.
可能存在这样的情况:你可能不需要设计模式,你可以简单地使用基本的面向对象设计原则。
Whether to use them or not depends on the scenario at hand. Each pattern talks about specific design problems and the standard solution for that. So before using them, spend a fair amount of time in analyzing your design issues and try to match it with the once-discussed in patterns.
是否使用设计模式,取决于你的实际情况。每个模式讨论特定的设计问题和标准的解决方案。所以在使用它们之前,花点时间,来分析你的设计问题,试图使用一种设计模式来与之对应,那么就可以使用这个模式,来解决你的设计问题了。
I would like to emphasize the point that the key to find the right pattern is to understand and identify the scenario that any pattern is trying to address.
我想强调一点,找到合适的模式的关键是理解和识别,用什么设计模式来解决问题。
Once you find the right pattern for your specific problem or scenario, you can apply it to your software design.
只要你发现了适用你的问题的模式,你就可以应用它,来解决你的软件设计出现的问题。
The many patterns【总共有多少设计模式】
There is no specific number of patterns, since they kind of evolve over time and the software industry has used and tested them. Having said that, there are folks like the “Gang of Four” that have well-documented and popularized them in the software development community. I also find SOLID design principles to be worth refer to.
这里没有固定数量的设计模式,因为软件行业使用和测试的设计模式,随时间而变化。说道这里,例如“Gang of Four”在软件社区很受欢迎。我也发现可靠的设计原则是值得参考的。
To summarize the discussion, I would like to say to start your design with a few basic design principles, like clean coding, loose coupling and modular design and so on and continue to evaluate design challenges with known and existing issues discussed in design patterns. After evaluation, if you find any matching pattern then go ahead and use it else stick to whatever you have designed.
最后总结一下,我想说的是,开始考虑为你的设计,使用一些设计原则,例如,干净的Coding,松耦合,模块化设计等等,并且继续评估设计模式中已知和已经存在的问题。评估完之后,只要发现能够解决你的问题的设计模式,那么就赶紧使用,推翻你之前的设计。
One last thing. Please don't force your application to use design patterns. Instead use them only if it makes sense.
最后一件事,不要强制为应用程序,应用设计模式。只有当应用设计模式的时候,能够解决问题,才去使用它。
I hope you have liked the article. Please share your comments.
我希望你喜欢这篇文章,请留下你的评论,谢谢~~~.
【翻译】设计模式学习系列1---【Design Patterns Simplified: Part 1【设计模式简述:第一部分】】的更多相关文章
- Design Patterns Simplified - Part 3 (Simple Factory)【设计模式简述--第三部分(简单工厂)】
原文链接:http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part3-factory/ Design ...
- Design Patterns Simplified - Part 2 (Singleton)【设计模式简述--第二部分(单例模式)】
原文链接: http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part-2-singleton/ De ...
- 设计模式学习系列6 原型模式(prototype)
原型模式(prototype)用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象.允许一个对象再创建另外一个新对象的时候根本无需知道任何创建细节,只需要请求圆形对象的copy函数皆可. 1 ...
- 设计模式学习系列9 外观模式Facade
1.概述 自己卖了一辆越野自行车,但毕竟不是自己定制的,买回来之后可能需要更改一下脚蹬,座皮,里程计数器或者刹车系统,假如将自行车看做一个整体系统,对我们而言使用的是自行车,然后我们对自己车构件的修改 ...
- 设计模式学习系列(一)——IOC设计原则
参考转载自IoC 之 2.1 IoC基础 ——跟我学Spring3
- 设计模式功能概述(Design Patterns)
1.Abstract Factory:提供一个创建一系列相关或相互依赖对象的接口,而无需指定它们具体的类. 2.Adapter:将一个类的接口转换成客户希望的另一个接口.Adapter模式使得原本由于 ...
- Scala学习系列(一)——Scala为什么是大数据第一高薪语言
为什么是Scala 虽然在大数据领域Java的使用更普及,Python也有后来居上的势头,但Scala一直有着不可动摇的地位.我们熟悉的Spark,Kafka,Flink都是由Scala完成了其核心代 ...
- 我的设计模式学习笔记------>Java设计模式总概况
设计模式(Design Pattern)的概念最早起源于建筑设计大师Alexander的<建筑的永恒方法>一书,尽管Alexander的著作是针对建筑领域的,但是他的观点实际上用用于所有的 ...
- 设计模式(Design Patterns)Java版
设计模式(Design Patterns) ——可复用面向对象软件的基础 设计模式(Design pattern)是一套被反复使用.多数人知晓的.经过分类编目的.代码设计经验的总结.使用设计模式是为了 ...
随机推荐
- HTML input小结
一.Input表示Form表单中的一种输入对象,其又随Type类型的不同而分文本输入框,密码输入框,单选/复选框,提交/重置按钮等,下面一一介绍. 1.type=text 输入类型是text,这是我们 ...
- Expert 诊断优化系列------------------给TempDB 降温
前面文章针对CPU.内存.磁盘.语句.等待讲述了SQL SERVER的一些基本的问题诊断与调优方式.为了方便阅读给出导读文章链接方便阅读: SQL SERVER全面优化-------Expert fo ...
- 企业IT管理员IE11升级指南【6】—— Internet Explorer 11面向IT专业人员的常见问题
企业IT管理员IE11升级指南 系列: [1]—— Internet Explorer 11增强保护模式 (EPM) 介绍 [2]—— Internet Explorer 11 对Adobe Flas ...
- 共享文件夹:The user has not been granted the requested logon type at this computer
场景重现 今天做一个项目测试,要用到虚拟机,于是在虚拟机(XP 32)上新建了一个共享的文件夹.然后我在Win7 机器上访问它得到如下的error 消息:
- Linux 挂载管理(mount)
标签:mount,umount 概述 在上一章增加linux操作系统空间中已经使用过了mount命令对分区进行挂载,这一章详细介绍挂载管理,该命令涉及的知识点也挺多的而且也还比较重要,是需要掌握的一个 ...
- Excel单元格发生变化后,使用Outlook给特定的人发邮件
自己在公司里面维护了一个小金库的Excel,当某个人的余额小于0的时候,Outlook会自动给这个人发一封邮件,同时将这个Excel附在邮件中,具体的代码如下: Public Function sen ...
- Swift 和 C# 的语法比较
昨天看到Jacob Leverich 写了一篇文章 Swift is a lot like Scala 介绍Swift 和 Scala 的语法对比,从这篇文章的确可以看到Swift 的语法和 Scal ...
- Module Zero概览
返回<Module Zero学习目录> 介绍 ABP框架的设计是独立于任何数据库模式的且尽可能地使用泛型.因此,它避开了一些要求数据存储的抽象和可选的概念(如审计日志,session管理和 ...
- Android入门(二十一)解析XML
原文链接:http://www.orlion.ga/685/ 解析XML常用的方式有两种,一种是PULL解析一种是SAX解析. 假设解析数据为: <apps> <app> ...
- c/c++多线程模拟系统资源分配(并通过银行家算法避免死锁产生)
银行家算法数据结构 (1)可利用资源向量Available 是个含有m个元素的数组,其中的每一个元素代表一类可利用的资源数目.如果Available[j]=K,则表示系统中现有Rj类资源K个. (2) ...