设计模式和架构模式有什么区别?

发布于 2024-10-04 05:16:45 字数 1706 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

黄昏下泛黄的笔记 2024-10-11 05:16:45

它需要详细的解释,但我会尽我所知尽力勾勒出差异。

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

一个大型复杂的软件会经历一系列不同层次的解构。从广义上讲,架构模式是工具。在较小的层面上,设计模式是工具,在实现层面上,编程范式是工具。

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

对于最简单的观点:

  • 编程范式 - 特定于编程语言
  • 设计模式 - 解决软件构建中反复出现的问题
  • 架构模式 - 基本的结构组织软件系统

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

设计模式通常与代码级共性相关。它提供了各种用于细化和构建较小子系统的方案。它通常受编程语言的影响。由于语言范式,某些模式显得微不足道。
设计模式是一种中等规模的策略,它充实了实体及其关系的一些结构和行为。

架构模式被视为比设计模式更高层次的通用性。
架构模式是涉及大规模组件、系统的全局属性和机制的高级策略。

图案是如何获得的?
通过:

  1. 重用、
  2. 分类
  3. 、最后抽象,提炼出共性。

如果您遵循上述想法。您将看到 Singleton 是一种“设计模式”,而 MVC 是处理关注点分离的“架构”模式之一。

尝试阅读:

  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 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.

For a most simplistic view:

  • 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. re-use,
  2. classification
  3. and finally abstraction to distill the commonality.

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.

Try reading on:

  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
神仙妹妹 2024-10-11 05:16:45

设计模式是众所周知的解决技术问题的模式,其方式已经被多次证明。
设计模式是用于创建可重用的面向对象软件的常见设计结构和实践。设计模式的例子有工厂模式、单例、外观、状态等。设计模式可以用来解决整个应用程序中较小的问题,并且比整体架构更容易注入、更改、添加。架构

模式是众所周知的解决模式软件应用程序架构问题。软件应用程序架构是定义满足所有技术和操作要求的结构化解决方案的过程。
应用程序的架构是代码的整体“组织”。不同架构的示例可能是 MVC、MVVM、MVP、n 层(即 UI-BLL-DAL)等。架构通常需要预先确定,并且一旦应用程序构建后通常很难更改。

Design Patterns are well known patterns for solving technical problems in a way that has proven itself many times.
Design patterns are common design structures and practices that make for creating reusable Object-Oriented software. Design pattern examples are Factory Pattern, Singleton, Facade, State, etc. Design patterns can be used to solve smaller problems throughout the application, and are much easier to inject, change, add than the overall architecture

architecture patterns are well known patterns for solving software application architecture problems. Software application architecture is the process of defining a structured solution that meets all of the technical and operational requirements.
Application's architecture is the overall 'organization' of the code. Examples of different Architectures might be MVC, MVVM, MVP, n-layer (i.e. UI-BLL-DAL), etc. The architecture typically needs to be decided up front and often is difficult to change once the application is built.

往事风中埋 2024-10-11 05:16:45

架构元素倾向于类或模块的集合,通常表示为框。关于架构的图代表了俯视的最高层次,而类图则处于最原子的层次。架构模式的目的是了解系统的主要部分如何组合在一起、消息和数据如何流过系统以及其他结构问题。
架构模式利用各种组件类型,每个组件类型通常由依次较小的模块组成。每个组件在架构中都有自己的职责
设计模式是针对较小应用程序颗粒的低级或类级设计模式。

欲了解更多信息:
https://www.oreilly.com/ideas/contrasting-架构模式与设计模式

Architectural elements tend towards collections of classes or modules, generally represented as boxes. Diagrams about architecture represent the loftiest level looking down, whereas class diagrams are at the most atomic level. The purpose of architecture patterns is to understand how the major parts of the system fit together, how messages and data flow through the system, and other structural concerns.
Architecture patterns utilize a variety of component types, each typically composed of successively smaller modules. Each component has a responsibility within the architecture
Design patterns are low level or class level design patterns for smaller particles of applications.

For more information:
https://www.oreilly.com/ideas/contrasting-architecture-patterns-with-design-patterns

蓝眼泪 2024-10-11 05:16:45

嗯,对于主要部分来说,这是语言问题。根据我的经验,就软件而言,设计和架构之间的界限是一条宽阔的河流,其宽度由水位决定,而水位又主要受营销季节的影响。一般来说,术语“设计”与最终用户认可的软件产品行为的一个重要方面一起使用,而“体系结构”代表软件的技术结构,即组件、库、协议以及满足需求所需的任何内容。设计。 “设计模式”有两个作用:第一,它们被视为解决一类(或多或少)标准问题的最佳实践,而不是产品;第二,它们被视为解决一类(或多或少)标准问题的最佳实践。第二,他们帮助开发人员进行沟通。继续使用单例的示例,它使我们能够通过使用这个词来了解其机制,而不是每次都解释,我们通过使用指定的数据空间(变量或其他)创建了一个实例,该数据空间设置在一种受控的方式,并且保证是唯一的,因为我们保护了类的构造函数等。所以恕我直言,你的问题的简短答案是:这取决于谁在说话。这有道理吗?

Well, for the main part it's a matter of the language. According to my experience the borderline between design and architecture, as far as software is concerned, is a broad river with it's width resulting from the water level which in turn is mainly influenced by the seasons of marketing. Generally the term "design" is used with a strong aspect of the software product's behavior as recognized by end users, whereas "architecture" stands for the technical structure of a software, i. e. the components, libraries, protocols and whatever it needs to fulfill the design. "Design patterns" take two roles: 1st they are regarded as best practices for solving a category of (more or less) standard problems, not prodiucts; 2nd they help the developers to communicate. Staying with your example of a Singleton, it allows us to know what the mechanics are about by just using the word, instead of explaining every time, that we created a single instance by using a designated dataspace (variable or whatever) which is set in a controlled manner and is guaranteed to be the only one, because we protected the constructor of the class etc. So IMHO the short answer to your question is: It depends on who is talking. Does that make some sense?

演多会厌 2024-10-11 05:16:45

原版《四人帮》一书将设计模式视为对象问题的常见解决方案面向编程。 C++ 和 Smalltalk 中给出了示例实现。那时候Java还没有被发明出来。

函数式程序员会说《四人帮》一书列出了面向对象编程中问题的缺陷。

设计在这里是一个非常模糊的词。它适用于方法、组件和系统级别。

我认为设计模式是方法或组件级别的常见解决方案。

架构模式的范围更广泛,适用于组件系统。

模式作为常见问题的建议解决方案的想法在整个范围内都适用。

The original Gang of Four book captured design patterns as common solutions to problems in object-oriented programming. Example implementations were given in C++ and Smalltalk. Java hadn't been invented yet.

Functional programmers would say that the Gang of Four book listed flaws to problems in object-oriented programming.

Design is such a fuzzy word here. It applies at the level of methods, components, and systems.

I think of design patterns as common solutions at the method or component level.

Architecture patterns are broader in scope and apply to systems of components.

The idea of a pattern as a suggeste solution to a common problem holds across the spectrum.

潇烟暮雨 2024-10-11 05:16:45

设计模式与架构模式的范围不同,它们更加本地化,​​对代码库的影响较小,它们影响代码库的特定部分,例如:

How to instantiate an object when we only know what type needs to be instantiated at run time (maybe a Factory Class?)
How to make an object behave differently according to its state (maybe a state machine, or a Strategy Pattern?)

架构模式具有广泛的影响在代码库上,通常会水平地(即如何在层内构造代码)或垂直地(即如何将请求从外层处理到内层并返回)影响整个应用程序。架构模式示例:模型-视图-控制器、模型-视图-视图模型

Design Patterns differ from Architectural Patterns in their scope, they are more localized, they have less impact on the code base, they impact a specific section of the code base, for example:

How to instantiate an object when we only know what type needs to be instantiated at run time (maybe a Factory Class?)
How to make an object behave differently according to its state (maybe a state machine, or a Strategy Pattern?)

Architectural Patterns have an extensive impact on the code base, most often impacting the whole application either horizontally (ie. how to structure the code inside a layer) or vertically (ie. how a request is processed from the outer layers into the inner layers and back). Examples of Architectural Patterns: Model-View-Controller, Model-View-ViewModel

晒暮凉 2024-10-11 05:16:45

如果我简单地说,

架构控制应用程序中的数据流,即应用程序中各个组件之间的数据流如何

设计模式处理您应用于将大型单元分解为的任何破坏可管理的块

If i put this very simply

Architecture governs data flow in app i.e. how the data flows between various components in app

Design Pattern deals with any destruct you apply to break a large unit into manageable chunks

暗喜 2024-10-11 05:16:45

架构模式就像一个蓝图设计模式实际实现。

更多相关内容:

The architectural pattern is like a blueprint and the design pattern is the actual implementation.

More on it:

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文