ArticleslgStudy

computer science

GRASP (object-oriented design)

GRASP (object-oriented design) is a computer science topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand GRASP (object-oriented design) rather than just read about it. In short: General responsibility assignment software patterns (or principles), abbreviated GRASP, is a set of "nine fundamental principles in object design and responsibility assignment" first published by Craig Larman in his 1997 book Applying UML and Patterns. The different patterns and principles used in GRASP are controller, creator, indirection, information expert, low coupling, high cohesion, polymorphism, protected var…

Key takeaways

  • GRASP (object-oriented design) belongs to computer science; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect GRASP (object-oriented design) to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of GRASP (object-oriented design) from memory before moving on to harder problems.

Reference excerpt

General responsibility assignment software patterns (or principles), abbreviated GRASP, is a set of "nine fundamental principles in object design and responsibility assignment" first published by Craig Larman in his 1997 book Applying UML and Patterns. The different patterns and principles used in GRASP are controller, creator, indirection, information expert, low coupling, high cohesion, polymorphism, protected variations, and pure fabrication. All these patterns solve some software problems common to many software development projects. These techniques have not been invented to create new ways of working, but to better document and standardize old, tried-and-tested programming principles in object-oriented design. Larman states that "the critical design tool for software development is a mind well educated in design principles. It is not UML or any other technology." Thus, the GRASP principles are really a mental toolset, a learning aid to help in the design of object-oriented software.

Patterns In object-oriented design, a pattern is a named description of a problem and solution that can be applied in new contexts; ideally, a pattern advises us on how to apply its solution in varying circumstances and considers the forces and trade-offs. Many patterns, given a specific category of problem, guide the assignment of responsibilities to objects.

Information expert

Problem: What is a basic principle by which to assign responsibilities to objects?Solution: Assign responsibility to the class that has the information needed to fulfill it. Information expert (also expert or the expert principle) is a principle used to determine where to delegate responsibilities such as methods, computed fields, and so on. Using the principle of information expert, 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. This will lead to placing the responsibility on the class with the most information required to fulfill it. Related pattern or principle: low coupling, high cohesion

Creator

The creation of objects is one of the most common activities in an object-oriented system. Which class is responsible for creating objects is a fundamental property of the relationship between objects of particular classes. Problem: Who creates object A?Solution: In general, assign class B the responsibility to create object A if one, or preferably more, of the following apply:

Instances of B contain or compositely aggregate instances of A Instances of B record instances of A Instances of B closely use instances of A Instances of B have the initializing information for instances of A and pass it on creation. Related pattern or principle: low coupling, factory

Controller The controller pattern assigns the responsibility of dealing with system events to a non-UI class that represents the overall system or a use case scenario. A controller object is a non-user interface object responsible for receiving or handling a system event. Problem: Who should be responsible for handling an input system event?Solution: A use case controller should be used to deal with all system events of a use case, and may be used for more than one use case. For instance, for the use cases Create User and Delete User, one can have a single class called UserController, instead of two separate use case controllers. Alternatively a facade controller would be used; this applies when the object with responsibility for handling the event represents the overall system or a root object. The controller is defined as the first object beyond the UI layer that receives and coordinates ("controls") a system operation. The controller should delegate the work that needs to be done to other objects; it coordinates or controls the activity. It should not do much work itself. The GRASP Controller can be thought of as being a part of the application/service layer (assuming that the application has made an explicit distinction between the application/service layer and the domain layer) in an object-oriented system with common layers in an information system logical architecture. Related pattern or principle: command, facade, layers, pure fabrication

Indirection The indirection pattern supports low coupling and reuses potential between two elements by assigning the responsibility of mediation between them to an intermediate object. An example of this is the introduction of a controller component for mediation between data (model) and its representation (view) in the model-view-controller pattern. This ensures that coupling between them remains low. Problem: Where to assign responsibility, to avoid direct coupling between two (or more) things? How to de-couple objects so that low coupling is supported and reuse potential remains higher? Solution: Assign the responsibility to an intermediate object to mediate between other components or services so that they are not directly coupled. The intermediary creates an indirection between the other components.

Low coupling

Coupling is a measure of how strongly one element is connected to, has knowledge of, or relies on other elements. Low coupling is an evaluative pattern that dictates how to assign responsibilities for the following benefits:

lower dependency between the classes, change in one class having a lower impact on other classes, higher reuse potential.

High cohesion

High cohesion is an evaluative pattern that attempts to keep objects appropriately focused, manageable and understandable. High cohesion is generally used in support of low coupling. High cohesion means that the responsibilities of a given set of elements are strongly related and highly focused on a rather specific topic. Breaking programs into classes and subsystems, if correctly done, is an example of activities that increase the cohesive properties of named classes and subsystems. Alternatively, low cohesion is a situation in which a set of elements, of e.g., a subsystem, has too many unrelated responsibilities. Subsystems with low cohesion between their constituent elements often suffer from being hard to comprehend, reuse, maintain and change as a whole.

Polymorphism

… excerpt ends here. Continue reading the full article.

Worked examples

Example 1 — a first encounter with GRASP (object-oriented design)

Start with the simplest possible case. Write down what GRASP (object-oriented design) claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In computer science, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to GRASP (object-oriented design) before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about GRASP (object-oriented design) ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of GRASP (object-oriented design)

In research
GRASP (object-oriented design) appears in computer science research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses GRASP (object-oriented design) in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
GRASP (object-oriented design) is common in secondary-school and first-year university syllabi. It links to neighbouring topics Mnemonic acronyms, Programming principles, Software design, so understanding it makes those chapters shorter.
In everyday life
Look for GRASP (object-oriented design) outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “GRASP (object-oriented design)” →

How to study GRASP (object-oriented design) in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what GRASP (object-oriented design) means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain GRASP (object-oriented design) out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is GRASP (object-oriented design) in simple terms?

General responsibility assignment software patterns (or principles), abbreviated GRASP, is a set of "nine fundamental principles in object design and responsibility assignment" first published by Craig Larman in his 1997 book Applying UML and Patterns. The different patterns and principles used in…

Why does GRASP (object-oriented design) matter?

Because it connects several computer science ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study GRASP (object-oriented design)?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on GRASP (object-oriented design).

Tags

  • Mnemonic acronyms
  • Programming principles
  • Software design

Keep exploring