GRASP is an object oriented design and is used for general responsibility assignment software.
The General Responsibility Assignment Software Patterns (or Principles), abbreviated GRASP, is a set of nine fundamental principles in object design and responsibility assignment.
There are different patterns and principles used in GRASP.Many software development projects use these patterns to solve software problems.To better document and standardize old, tried-and-tested programming principles in object-oriented design, these techniques have not been invented to create new ways of working.
The critical design tool for software development is a mind well educated in design principles.It isn't any other technology.The GRASP principles are a learning aid to help in the design of object-oriented software.
In object-oriented design, a pattern is a named description of a problem and solution that can be applied in new contexts.Many patterns lead to the assignment of responsibilities to objects.
What is the basic principle for assigning responsibilities to objects?The solution is to assign responsibility to the class that has the information.
Information expert is a principle used to determine where to delegate responsibilities such as methods, computed fields, and so on.
A general approach to assigning responsibilities is to look at a given responsibility, determine the information needed to fulfill it, and then determine where that information is stored.
The responsibility will be placed on the class with the most information required.[3]:17:11
One of the most common activities in an object oriented system is the creation of objects.The relationship between objects of particular classes is dependent on which class is responsible for creating them.
Who created object A?If one or more of the following apply, assign class B the responsibility to create object A.
The controller pattern assigns the responsibility of dealing with system events to a non-UI class.A controller object is a non- user interface object.
Who should be in charge of handling an input system event?A use case controller should be used to deal with all system events of use cases.One can have a single class called UserController, instead of two separate use case controllers.
The controller is the first object beyond theUI layer that receives and coordinates a system operation.The controller should be in charge of the work that needs to be done to other objects.It shouldn't do much work on its own.The GRASP controller can be thought of as a part of the application/service layer in an object-oriented system with common layers.
The indirection pattern supports lowcoupling and reuses potential between two elements by assigning the responsibility of mediation between them to an intermediate object.The controller component for mediation between data and its representation in the model-view control pattern is an example of this.This ensures that they don't get too close.
There is a problem of where to assign responsibility.How to make objects compatible so that reuse potential remains high?
The solution is to assign the responsibility to an intermediate object so that they are not directly coupled.There is an indirection between the other components.
It is a measure of how connected one element is to another element.There is an evaluative pattern that dictates how to assign responsibilities.
High cohesion attempts to keep objects manageable and understandable.In support of lowcoupling, high cohesion is used.The responsibilities of a given element are related and focused.Activities that increase the cohesive properties of a system include breaking programs into classes and subsystems.A situation in which a given element has too many unrelated responsibilities is called low cohesion.It is hard to comprehend, reuse, maintain and change elements with low cohesion.[3]: 314–335.
The responsibility for defining the variation of behaviors based on type is assigned to the type for which it happens.This can be achieved using polymorphic operations.The user of the type should use polymorphic operations.