quiz image

GRASP Patterns and Responsibilities

RichTourmaline9881 avatar
RichTourmaline9881
·
·
Download

Start Quiz

Study Flashcards

30 Questions

What does the acronym GRASP stand for?

General Responsibility Assignment Software Patterns

What is the primary purpose of GRASP patterns?

To assist in methodical object design

What is a responsibility in UML?

A contract or obligation of a classifier

What is the relationship between GRASP patterns and object design?

GRASP patterns help in understanding essential object design

What is the significance of GRASP patterns?

They are used to document intuitive knowledge

According to the quote, what is the most likely way for the world to be destroyed?

By accident

Who created the acronym GRASP?

Craig Larman

What is the significance of responsibilities in object design?

They are related to the obligations of an object

What is the focus of GRASP patterns?

Assigning responsibilities to classes

What is the creative step during design, according to GRASP?

Assignment of responsibilities

Which GRASP pattern aims to minimize dependencies between classes?

Low Coupling

According to the Information Expert pattern, which class should be responsible for creating instances of a new bank account?

Bank

Which GRASP pattern is related to handling system events or coordinating activities?

Controller

What is the primary goal of the Low Coupling pattern?

Minimizing dependencies between classes

Which class should be responsible for calculating interest on a bank account according to the Information Expert pattern?

BankAccount

What is the purpose of the Observer pattern in the Low Coupling pattern?

To notify interested parties of changes in bank account balances

Which GRASP pattern is related to assigning responsibilities to classes that have the necessary information?

Information Expert

Which class should be responsible for transferring funds between bank accounts according to the Controller pattern?

TransactionController

What is the primary goal of the High Cohesion pattern?

Promoting high cohesion

Which GRASP pattern aims to promote high cohesion by assigning responsibilities to classes that have the necessary information?

Information Expert

What is the primary focus of 'doing' responsibilities in an object?

Initiating action in other objects

What is the purpose of GRASP patterns?

To provide guidelines for assigning responsibilities to objects

What is the main idea behind the Information Expert pattern?

Assigning a responsibility to the class that has the most knowledge

What is the problem that the Information Expert pattern solves?

What is a basic principle by which to assign responsibilities to objects

What is the main characteristic of a 'knowing' responsibility?

Having knowledge about private encapsulated data

What is the purpose of the Creator pattern?

To assign the responsibility of creating instances to the class that has the most knowledge

How many GRASP patterns are there?

9

What is the name of the GRASP pattern that helps in assigning responsibilities to objects based on the information they have?

Information Expert

What is a GRASP pattern?

A named problem/solution pair that can be applied in new contexts

Which of the following is NOT a type of responsibility in an object?

Storing

Study Notes

GRASP Patterns

  • GRASP (General Responsibility Assignment Software Patterns) is a methodical approach to learning basic object design
  • GRASP encompasses nine object-oriented design principles related to creating responsibilities for classes
  • These principles can also be viewed as design patterns

Responsibilities

  • A responsibility is a contract or obligation of a classifier
  • There are two types of responsibilities:
    • Doing (e.g., creating an object, initiating action in other objects, controlling and coordinating activities)
    • Knowing (e.g., knowing about private encapsulated data, related objects, or things that can be derived or calculated)

GRASP Patterns

  • Experienced object-oriented developers build up a repertoire of general principles and idiomatic solutions that guide them in creating software
  • A pattern is a named problem/solution pair that can be applied in new contexts

GRASP Patterns - Examples

  • Creator: Assign the responsibility of creating instances of a class to the class that has the most knowledge about when and how to create them
    • Example: Assigning the responsibility of creating new bank account instances to the Bank class or AccountManager class
  • Information Expert (or just Expert): Assign a responsibility to the class that has the necessary information to fulfill it
    • Example: Assigning the responsibility of calculating interest on a bank account to the BankAccount class
  • Low Coupling: Aims for classes to have minimal dependencies on each other, facilitating easier maintenance and flexibility in the system
    • Example: Implementing an Observer pattern to notify interested parties of changes in bank account balances without tightly coupling them to the BankAccount class
  • Controller: Assign the responsibility of handling system events or coordinating activities to a controller class
    • Example: Assigning the responsibility of handling the process of transferring funds between bank accounts to a TransactionController class

Additional GRASP Patterns

  • High Cohesion: Aims to keep a class focused on a single responsibility
  • Polymorphism: Allows for multiple forms of a class, providing flexibility in object decomposition
  • Pure Fabrication: Creates an artificial class to resolve a problem that doesn't have a natural class
  • Indirection: Decouples objects that would otherwise be tightly coupled
  • Protected Variations: Encapsulates the behavior of an object, allowing for changes without affecting other objects

Learn about GRASP, a methodical approach to object-oriented design, and understand responsibilities in classes, including the two types: doing and knowing.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

GRASP Patterns in Object Design
5 questions

GRASP Patterns in Object Design

InestimableRainforest avatar
InestimableRainforest
Use Quizgecko on...
Browser
Browser