设计模式和架构模式有什么区别? [英] What's the difference between design patterns and architectural patterns?

查看:31
本文介绍了设计模式和架构模式有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们在互联网上阅读设计模式时,我们注意到有 3 类:

When we read about design patterns on the internet we note that there are 3 categories:

  • 创意
  • 结构
  • 行为

但是当我们创建软件架构时,我们会考虑 MVP、MVC 或 MVVM.

But when we create the architecture of a software, then we think about MVP, MVC or MVVM.

例如,在创建模式中,我发现了单例模式,但我也在我的 MPV 中使用了单例模式.

For example, among creational patterns I found the singleton pattern, but I have also used singleton in my MPV.

所以我的问题是:设计模式是产品的整体结构吗?

So my question is: Is a design pattern a over all structure of a product?

  • 如果是,那么单例如何成为设计模式?因为我可以在我的应用程序的任何地方使用它.基本上,它仅限于在内存中一次创建一个实例,但是这个概念不是定义了软件的设计方式吗?

  • If yes, then how singleton can be a design pattern? Because I can use it anywhere in my application. Basically, it is restricted only to create one instance at a time in memory, but doesn't this concept define how software is designed?

如果不是,那么MVP、MVC和MVVM在三类模式中的位置在哪里?软件的设计和架构之间有什么区别?

If not, then where are MVP, MVC and MVVM in the three categories of patterns? And what is the difference between design and architecture of software?

推荐答案

它需要一个详细的解释,但我将尽我所知尝试勾画差异.

It requires a detailed explanation but I will try to sketch the differences to best of my knowledge.

模式是您在程序中发现的精炼共性.它使我们能够解构大型复杂结构并使用简单部件进行构建.它为一类问题提供了通用的解决方案.

Patterns are distilled commonality that you find in programs. It allows us to deconstruct a large complex structure and build using simple parts. It provides a general solution for a class of problems.

一个大型复杂的软件要经过一系列不同层次的解构.总体而言,架构模式就是工具.在较小的层面上,设计模式是工具,在实现层面,编程范式是工具.

A large complex software goes through a series of deconstruction at different levels. At large level, architectural patterns are the tools. At smaller level, design patterns are the tools and at implementation level, programming paradigms are the tools.

一个模式可以出现在非常不同的层次上.请参阅分形.快速排序、归并排序都是将一组元素按顺序组织起来的算法模式.

A pattern can occur at very different levels. See Fractals. Quick sort, Merge sort are all algorithmic patterns for organizing a group of elements in a order.

对于最简单的视图:

  • 编程范式 - 特定于编程语言
  • 设计模式 - 解决软件构建中反复出现的问题
  • 架构模式 - 软件系统的基本结构组织
  • Programming paradigms - specific to programming language
  • Design patterns - solves reoccurring problems in software construction
  • Architectural patterns - fundamental structural organization for software systems

习语是特定于范式和特定于语言的编程技术,用于填充低级细节.

Idioms are paradigm-specific and language-specific programming techniques that fill in low-level details.

设计模式通常与代码级别的共性相关联.它提供了各种改进和构建更小的子系统的方案.它通常受编程语言的影响.由于语言范式,一些模式变得无足轻重.设计模式是一种中等规模的策略,可充实实体及其关系的某些结构和行为.

Design patterns are usually associated with code level commonalities. It provides various schemes for refining and building smaller subsystems. It is usually influenced by programming language. Some patterns pale into insignificance due to language paradigms. Design patterns are medium-scale tactics that flesh out some of the structure and behavior of entities and their relationships.

虽然架构模式被视为比设计模式更高级别的共性.架构模式是涉及大规模组件、系统的全局属性和机制的高级策略.

While architectural patterns are seen as commonality at higher level than design patterns. Architectural patterns are high-level strategies that concerns large-scale components, the global properties and mechanisms of a system.

模式是如何获得的?通过:

How are patterns obtained? Through:

  1. 重复使用,
  2. 分类
  3. 最后通过抽象来提炼共性.

如果您遵循了上述想法.您会看到单例是一种设计模式",而 MVC 是处理关注点分离的架构"模式之一.

If you have followed the thoughts laid above. You will see that Singleton is a "design pattern" while MVC is one of the "architectural" pattern to deal with separation of concerns.

尝试阅读:

  1. http://en.wikipedia.org/wiki/Architectural_pattern_(computer_science)
  2. http://en.wikipedia.org/wiki/Design_pattern
  3. http://en.wikipedia.org/wiki/Anti-pattern

这篇关于设计模式和架构模式有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆