I am really confused about the difference between GOF and GRASP patterns? even both contribute to improved Object oriented practices
问题:
回答1:
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
回答2:
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.
- SOLID Priciples
- GRASP Principles
- Law of Demeter-LoD
- 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.