Table of Contents
1. Responsibility allocation and responsibility-driven design
2. Analysis of GRASP patterns one by one
Home Backend Development C#.Net Tutorial A brief discussion on GRASP software development model

A brief discussion on GRASP software development model

Mar 31, 2017 am 11:52 AM

Are you a good software developer? Do you know GRASP? GRASP software development model, the full name is General Responsibility Assignment Software Patterns, is another software development model as famous as the famous software model GoF (Gang of Four, the 23 software development models we often call). model. But unlike GoF, it does not propose some specific software organizational structures, but rather proposes what we should follow in the process of abstracting real-world business functions into concrete objects in software development. Some Basic Principles. Only by following these basic principles can we develop high-quality software. For the software projects we want to develop, we don’t have to use factory pattern, we don’t have to use single case pattern, we don’t have to use observer pattern, but It is impossible for us not to abstract real-world business functions into concrete objects in software development. From this perspective, we need to improve the quality of our software development. A deep understanding of GRASP is more important than a deep understanding of GoF. But I see that there are many articles introducing GoF and few articles introducing GRASP. Because of this, I now introduce GRASP to everyone.
GRASP contains 9 patterns, which are 9 basic principles. This is explained in depth in the classic book "UML and Pattern Application" by software design guru Craig Larman. GRASP is called the General Responsibility Assignment Software Pattern. To understand GRASP, the first question we must understand is why we need to assign responsibilities during the object analysis and design process.

1. Responsibility allocation and responsibility-driven design

At the beginning of a software project, we usually need to conduct a requirements analysis to understand what kind of software the customer needs to design and what functions the software should have. Requirements analysis understands the business functions required by customers in the real world. Each business function is often a business process, that is, the business process that customers continue to complete in their daily work. At the same time, in the user's problem world, there must be some things or things that are related to each other.
Take a software review management system as an example. The business requirements of the review management system are as follows:
1. The review organizer develops a review plan, submits it to the leader for approval, and then notifies the reviewers via email.
2. The reviewers are notified to review the review objects respectively, fill in the review form, and can raise questions about the review objects.
3. The review organizer summarizes the reviewers' questions and holds a review meeting to discuss these questions. At the meeting, some questions became problems, some questions were not problems, and some still could not be confirmed.
4. After the meeting, the review organizer will sort out the questions and form a review report, and then the reviewers will vote on whether the review is passed or not. Finally, the review organizer summarizes the voting results and forms a review conclusion.
5. Review organizers track resolution of issues.
Through the description of the above requirements, it is not difficult for us to find related things in the entire problem world: review organizer, review plan, reviewer, review object, review form, questions, review report, review conclusion, and questions. It is not difficult for us to analyze the relationship between these things. For example, the review plan and reviewers are one-to-many, while the review report and review conclusions are one-to-one.
In RUP, business requirements will form use cases Model and use cases in their description documents, and things and their relationships will form objects in the domain model. Of course, how to make use case models and domain models is beyond this article Regarding the scope of the discussion, interested friends can read relevant articles.
The objects in the domain model will become the basis for forming specific objects in software development (what objects are formed in software development is determined according to the specific needs of software development, and does not necessarily have to be consistent with the objects of the domain model). The use cases in the use case model will be implemented by assigning behaviors to these objects. Now the question arises, how should the functions in the use case model, or a series of behaviors, be assigned to these objects. In other words, in order to complete the same task, I can assign behavior A to object X or to object Y. Although my specific implementation of behavior A is different when I hand it over to object X and when I hand it over to object Y, both can complete the task of behavior A. So, should I hand it over to object X or object Y? Is there a basic principle? Yes, that is to allocate tasks according to responsibilities. Although in theory, I can define objects arbitrarily, make objects meaningless, or perform arbitrary tasks, but usually we do not design in this way. Usually we connect objects with real-world objects, such as designing a review plan object and reviewer object. And we should achieve "low representation difference" when designing objects. Low representation difference means that the objects we design should be as consistent as possible with real-world objects. For example, we design an object called "reviewer" because we have reviewers in the real world. At the same time, the behaviors we assign to reviewer objects should be as consistent as possible with the real world, such as adding reviewers, modifying reviewers, and obtaining reviewer information. So which behaviors should be assigned to this object should be determined by responsibilities.
We design the objects in the software system through analysis of the real world, or analysis of the domain model. At this time, we should assign responsibilities to each object. What is the responsibility of an object? Of course, it is defined through the analysis of the real world and the tasks that this object should complete. For example, the responsibility of the reviewer object is to access data related to the reviewer. Of course, the responsibility of an object does not necessarily have to be the same. For example, the review plan contains the sub-items of the review object and the reviewer, so it can handle the information access of the review object and reviewer on behalf of the review object when the work is not busy. But an object should not have too many responsibilities (just 2 or 3) and should be highly related. For example, if the object of the evaluation form is assigned the responsibility to process the evaluation form and also process the data of the evaluation plan, this is called responsibility-independent.
Responsibility distribution is now generally recognized as a principle that an excellent software design should follow. It has the following benefits:
1. Low representation differences make software clearly structured and easy to understand because software development is not a one-person affair. In software projects developed by multiple people, a clear software structure can avoid unnecessary errors caused by developers' misunderstandings.
2. Easy to maintain and change. If there is a problem with the review plan or needs to be modified, we will go to the review plan. If it is a problem with the reviewer, we will go to the reviewer, and it will never have anything to do with other parties.
This kind of object design and component approach that considers objects, responsibilities, and collaboration is called "Responsibility Drive Design (RDD)". Responsibility-driven design involves first designing use case models, use case model descriptions, operation contracts, system sequence diagrams, domain models, and glossaries, and then step by step making analysis models and design models, and writing interaction diagrams and class diagrams for each function. I won’t go into details about the complicated process here. But please pay attention to a very important detail. As we said earlier, objects in software systems are abstracted from the real world. The allocation of object responsibilities is based on the definition of the object, assigning some few and highly related tasks. However, even if we follow these principles, we still have considerable design flexibility. Different people still have different designs for the same function based on their own understanding. GRASP is translated as "General Responsibility Assignment Software Pattern" in Chinese, which puts forward several basic principles for the issue of responsibility assignment in object analysis and design. At the same time, these basic principles should also be grasped to a certain extent, that is, they are not applicable in all situations, nor are they an absolute indicator. For example, low coupling does not mean absolute non-coupling. Without coupling, software cannot be designed; high cohesion cannot be infinitely high, otherwise the system will be complicated and abnormal.


2. Analysis of GRASP patterns one by one

GRASP softwareDesign patternIncludes 9 patterns: Creator, Information Expert, Low Coupling , Controller, high cohesion, polymorphism, pure fiction, indirectness, prevention of mutation.

The above is the detailed content of A brief discussion on GRASP software development model. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Clair Obscur: Expedition 33 - How To Get Perfect Chroma Catalysts
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1677
14
PHP Tutorial
1278
29
C# Tutorial
1257
24
The Continued Relevance of C# .NET: A Look at Current Usage The Continued Relevance of C# .NET: A Look at Current Usage Apr 16, 2025 am 12:07 AM

C#.NET is still important because it provides powerful tools and libraries that support multiple application development. 1) C# combines .NET framework to make development efficient and convenient. 2) C#'s type safety and garbage collection mechanism enhance its advantages. 3) .NET provides a cross-platform running environment and rich APIs, improving development flexibility.

C# as a Versatile .NET Language: Applications and Examples C# as a Versatile .NET Language: Applications and Examples Apr 26, 2025 am 12:26 AM

C# is widely used in enterprise-level applications, game development, mobile applications and web development. 1) In enterprise-level applications, C# is often used for ASP.NETCore to develop WebAPI. 2) In game development, C# is combined with the Unity engine to realize role control and other functions. 3) C# supports polymorphism and asynchronous programming to improve code flexibility and application performance.

Deploying C# .NET Applications to Azure/AWS: A Step-by-Step Guide Deploying C# .NET Applications to Azure/AWS: A Step-by-Step Guide Apr 23, 2025 am 12:06 AM

How to deploy a C# .NET app to Azure or AWS? The answer is to use AzureAppService and AWSElasticBeanstalk. 1. On Azure, automate deployment using AzureAppService and AzurePipelines. 2. On AWS, use Amazon ElasticBeanstalk and AWSLambda to implement deployment and serverless compute.

C# and the .NET Runtime: How They Work Together C# and the .NET Runtime: How They Work Together Apr 19, 2025 am 12:04 AM

C# and .NET runtime work closely together to empower developers to efficient, powerful and cross-platform development capabilities. 1) C# is a type-safe and object-oriented programming language designed to integrate seamlessly with the .NET framework. 2) The .NET runtime manages the execution of C# code, provides garbage collection, type safety and other services, and ensures efficient and cross-platform operation.

.NET Framework vs. C#: Decoding the Terminology .NET Framework vs. C#: Decoding the Terminology Apr 21, 2025 am 12:05 AM

.NETFramework is a software framework, and C# is a programming language. 1..NETFramework provides libraries and services, supporting desktop, web and mobile application development. 2.C# is designed for .NETFramework and supports modern programming functions. 3..NETFramework manages code execution through CLR, and the C# code is compiled into IL and runs by CLR. 4. Use .NETFramework to quickly develop applications, and C# provides advanced functions such as LINQ. 5. Common errors include type conversion and asynchronous programming deadlocks. VisualStudio tools are required for debugging.

C# .NET: Building Applications with the .NET Ecosystem C# .NET: Building Applications with the .NET Ecosystem Apr 27, 2025 am 12:12 AM

How to build applications using .NET? Building applications using .NET can be achieved through the following steps: 1) Understand the basics of .NET, including C# language and cross-platform development support; 2) Learn core concepts such as components and working principles of the .NET ecosystem; 3) Master basic and advanced usage, from simple console applications to complex WebAPIs and database operations; 4) Be familiar with common errors and debugging techniques, such as configuration and database connection issues; 5) Application performance optimization and best practices, such as asynchronous programming and caching.

C# .NET Development: A Beginner's Guide to Getting Started C# .NET Development: A Beginner's Guide to Getting Started Apr 18, 2025 am 12:17 AM

To start C#.NET development, you need to: 1. Understand the basic knowledge of C# and the core concepts of the .NET framework; 2. Master the basic concepts of variables, data types, control structures, functions and classes; 3. Learn advanced features of C#, such as LINQ and asynchronous programming; 4. Be familiar with debugging techniques and performance optimization methods for common errors. With these steps, you can gradually penetrate the world of C#.NET and write efficient applications.

C# and .NET: Understanding the Relationship Between the Two C# and .NET: Understanding the Relationship Between the Two Apr 17, 2025 am 12:07 AM

The relationship between C# and .NET is inseparable, but they are not the same thing. C# is a programming language, while .NET is a development platform. C# is used to write code, compile into .NET's intermediate language (IL), and executed by the .NET runtime (CLR).

See all articles