GOF 和 GRASP 设计模式有什么区别

发布于 2024-10-03 21:22:57 字数 53 浏览 0 评论 0 原文

我真的很困惑 GOF 和 GRASP 模式之间的区别? 甚至两者都有助于改进面向对象的实践

I am really confused about the difference between GOF and GRASP patterns?
even both contribute to improved Object oriented practices

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

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

发布评论

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

评论(2

三生殊途 2024-10-10 21:22:57

简短回答
GoF提到了设计模式。而GRASP设计原则。设计原则比设计模式更抽象。

长答案
软件工程的主要目的是开发合适的软件。 SDLC 呈现了顶层软件工程的步骤。 软件设计是 SLDC 步骤之一。而面向对象的软件设计是一种流行的软件设计方法。

要执行面向对象的软件设计,有多种不同名称的资源(书籍、教程和论文),例如:指南、原则、启发式、模式、样式等。

之间的差异这些名称是它们的抽象。顶层是主要原则,其他级别是有助于实现这些主要原则的细节。

顶层

在顶层,教程介绍主要原则。 (基于面向对象的分析和应用程序设计,Grady Booch 等人,1991 年)
面向对象的主要原则

  • 抽象
  • 封装(信息隐藏)
  • 层次结构(继承、聚合)
  • 模块化(高内聚、松散耦合)

后续的所有原则和模式都与这个主要原则相关,并试图支持和改进它们。

第二级

在第二级资源中,有原则,并试图支持和改进面向对象的主要原则。

  1. SOLID 原则
  2. GRASP 原则
  3. 德墨忒尔法则-LoD
  4. 等(其他单一命名原则,如LoD)

第三级

此级别的资源称为设计模式Gof(四人帮)有第一本关于设计模式的书。有 23 种设计模式支持面向对象设计的主要原则和其他原则。

GoF之后,出现了许多关于在特定编程语言和特定框架中使用设计模式的书籍(例如J2EE设计模式、JQuery设计模式等)。

设计模式更加详细,并且非常接近编程语言。然而,主要原则(顶层)和原则(第二层)是如此抽象。

第四级

在这一级中,资源称为:启发式

这个级别的资源比其他组更详细、更具体。

最好的资源是Object Oriented Design Heuristics(72 Heuristics),Arthur J. Riel 的书,1996

Fifth Level

在最后一级,有Guideline

书中所有的不要做避免……指南都可以集中在这个组中。

Short Answer:
GoF are mentioned to Design Patterns. And GRASP are Design Principles. Design Principles are so abstract than Design Patterns.

Long Answer:
The main purpose of Software Engineering is developing a proper software. SDLC presents the steps of Software Engineering in top level. Software Design is one of SLDC steps. And Object Oriented Software Design is a popular approach of Software Design.

To perform an Object Oriented Software Design, there are many kind of resources (in Books, Tutorials and Papers) with different names such as: Guidelines, Principles, Heuristics, Patterns, Styles and etc.

The differences between these names are the Abstraction of them. Top Level is the main principles and other levels are details that help to reach these main principles.

Top Level

At the top level, tutorials present Main Principles. (based on Object-Oriented Analysis and Design with Applications, Grady Booch, et al. 1991)
Object Oriented Main Principles

  • Abstraction
  • Encapsulation (Information Hiding)
  • Hierarchy (Inheritance, Aggregation)
  • Modularity (High Cohesion and Loosely Coupling)

All subsequent principles and patterns is related to this main principles and try to support and improve them.

Second Level

In the second level of resource there are Principles and trying to support and improve Main Principles of Object Orientation.

  1. SOLID Priciples
  2. GRASP Principles
  3. Law of Demeter-LoD
  4. and etc. (other single named principles like LoD)

Third Level

This level of resources called Design Patters. Gof (Gang of Four) have the first book about Design Patterns. There is 23 Design Patterns to support main principles and other principles of Object Oriented Design.

After GoF, many books written about using Design Patterns in specific programming language and specific frameworks (e.g. J2EE Deign Patterns, JQuery Design Patterns and etc.)

Design Patterns are more detailed and so close to programming language. However, Main Principles (at Top Level) and Principles (at Second Level) is so abstract.

Forth Level

In this level, resources called : Heuristics.

The resource of this level are so detailed and very specific than other groups.

The best resource is Object Oriented Design Heuristics (72 Heuristics) , Book by Arthur J. Riel, 1996

Fifth Level

At the final level, there are Guideline.

All Do It, Don't Do it, Avoid, ... guidelines in the books can be gather in this group.

紫竹語嫣☆ 2024-10-10 21:22:57

GOF 是模式,即针对重复出现的问题的经过验证的设计解决方案。 把握是原则和不依赖于任何特定的问题领域,因此在任何情况下都是如此

GOF are patterns i.e. proven design solutions to recurring problems. GRASP are principles and are not tied to any specific problem domain hence true in any scenario

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