星空网 > 软件开发 > ASP.net

【翻译】设计模式学习系列1

http://www.c-sharpcorner.com/UploadFile/19b1bd/design-patterns-simplified-part1/

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【什么时候使用设计模式】

【翻译】设计模式学习系列1

       这是一个非常中肯的问题,我们应该清楚设计模式的适用性。使用设计模式的时候,没有很好的评估,将会使得设计变得不必要的复杂。

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

关键词:设计模式

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

哈萨克斯坦物流:https://www.goluckyvip.com/tag/96673.html
柬埔寨物流陆运:https://www.goluckyvip.com/tag/96675.html
陆运物流柬埔寨:https://www.goluckyvip.com/tag/96676.html
物流柬埔寨陆运:https://www.goluckyvip.com/tag/96677.html
法罗群岛物流:https://www.goluckyvip.com/tag/96678.html
柬埔寨进口物流:https://www.goluckyvip.com/tag/96679.html
无锡旅游景点竹海 - 无锡的竹海:https://www.vstour.cn/a/363178.html
5月贾汪好玩的地方 贾汪哪有好玩的地方:https://www.vstour.cn/a/363179.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流