简体   繁体   English

GOF和GRASP设计模式之间的区别是什么?

[英]What is the Difference between GOF and GRASP design patterns

I am really confused about the difference between GOF and GRASP patterns? 我对GOF和GRASP模式之间的区别感到困惑吗? even both contribute to improved Object oriented practices 甚至两者都有助于改进面向对象的实践

GOF are patterns ie proven design solutions to recurring problems. GOF是模式,即经过验证的设计解决方案,可以反复出现问题。 GRASP are principles and are not tied to any specific problem domain hence true in any scenario GRASP是原则 ,并不依赖于任何特定的问题域,因此在任何情况下都是如此

Short Answer : 简答
GoF are mentioned to Design Patterns . 设计模式中提到了GoF And GRASP are Design Principles . GRASP设计原则 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. SDLC介绍了顶级软件工程的步骤。 Software Design is one of SLDC steps. 软件设计是SLDC步骤之一。 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) (基于面向对象的分析和应用设计,Grady Booch,等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 SOLID原则
  2. GRASP Principles GRASP原则
  3. Law of Demeter-LoD Demeter法则 - LoD
  4. and etc. (other single named principles like LoD) 等(其他单一命名的原则,如LoD)

Third Level 第三级

This level of resources called Design Patters . 这种级别的资源称为Design Patters Gof (Gang of Four) have the first book about Design Patterns. Gof (Gang of Four)有第一本关于设计模式的书。 There is 23 Design Patterns to support main principles and other principles of Object Oriented Design. 有23种设计模式支持面向对象设计的主要原则和其他原则。

After GoF, many books written about using Design Patterns in specific programming language and specific frameworks (eg J2EE Deign Patterns, JQuery Design Patterns and etc.) 在GoF之后,许多书籍都是在特定的编程语言和特定的框架中使用设计模式(例如J2EE设计模式,JQuery设计模式等)。

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 最好的资源是面向对象设计启发式 (72 Heuristics),由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. 所有这样不要这样做避免 ,......书中的指导方针可以聚集在这一组中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM