SWE202: GRASP Patterns in Software Construction

TantalizingCurl4549 avatar
TantalizingCurl4549
·
·
Download

Start Quiz

Study Flashcards

24 Questions

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

Bank

What is the main goal of the Low Coupling GRASP pattern?

To minimize dependencies between classes

Which GRASP principle is responsible for assigning the responsibility of handling system events or coordinating activities to a controller class?

Controller

What is the main advantage of using the Observer pattern in the GRASP principle of Low Coupling?

To notify interested parties of changes in bank account balances without tightly coupling them to the BankAccount class

According to the GRASP principle of Information Expert, which class should be responsible for calculating interest on a bank account?

BankAccount

What is the main goal of the High Cohesion GRASP pattern?

To assign a responsibility to the class that has the necessary information to fulfill it

Which GRASP principle is responsible for determining which class should handle the process of transferring funds between bank accounts?

Controller

What is the main benefit of using the GRASP patterns in system design?

To facilitate easier maintenance and flexibility in the system

What are the two types of responsibilities of an object?

Knowing and Doing

What does the 'doing' responsibility of an object include?

Initiating action in other objects

What is the primary purpose of GRASP patterns?

To assign responsibilities to objects

What is the problem solved by the Information Expert pattern?

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

Which GRASP pattern assigns the responsibility of creating instances of a class to the class that has the most knowledge about when and how to create them?

Creator

What is a characteristic of a GRASP pattern?

It is a named problem/solution pair that can be applied in new contexts

What is an example of a 'knowing' responsibility of an object?

Knowing about private encapsulated data

How many GRASP patterns are there?

9

What is the primary purpose of GRASP patterns?

To develop a methodical approach to object design

What is the relationship between responsibilities and behavior in an object?

Responsibilities are related to an object's behavior in terms of its obligations

Who is credited with creating the GRASP acronym?

Craig Larman

What is the focus of the four GRASP patterns to be presented?

Assigning responsibilities to classes

What is the quote about the most likely way for the world to be destroyed?

By accident

What is the definition of a responsibility in UML?

A contract or obligation of a classifier

What is the primary goal of GRASP patterns in software design?

To help understand essential object design

What is the significance of GRASP patterns in object design?

They are creative steps in the design process

Study Notes

GRASP Patterns

  • GRASP (General Responsibility Assignment Software Patterns) is an acronym created by Craig Larman to encompass nine object-oriented design principles related to creating responsibilities for classes.
  • GRASP patterns are a learning aid to help with fundamental object design and apply design reasoning in a methodical, rational, explainable way.

Responsibilities

  • A responsibility is a contract or obligation of a classifier.
  • There are two types of responsibilities:
    • Doing responsibilities: include doing something itself, initiating action in other objects, and controlling and coordinating activities in other objects.
    • Knowing responsibilities: include knowing about private encapsulated data, knowing about related objects, and knowing about things it can derive or calculate.

GRASP Patterns - Example

  • Pattern Name: Information Expert
  • Solution: Assign a responsibility to the class that has the information needed to fulfill it.
  • Problem it Solves: What is a basic principle by which to assign responsibilities to objects?

GRASP Patterns

  • There are nine GRASP patterns:
    • Creator
    • Information Expert (or just Expert)
    • Low Coupling
    • Controller
    • High Cohesion
    • Polymorphism
    • Pure Fabrication
    • Indirection
    • Protected Variations

GRASP Patterns - Creator

  • Pattern Name: Creator
  • Solution: Assign the responsibility of creating instances of a class to the class that has the most knowledge about when and how to create them.
  • Problem: Decide which class should be responsible for creating instances of a new bank account.

GRASP Patterns - Information Expert (or just Expert)

  • Pattern Name: Information Expert
  • Solution: Assign a responsibility to the class that has the necessary information to fulfill it, promoting high cohesion and minimizing coupling.
  • Problem: Determine which class should be responsible for calculating interest on a bank account.

GRASP Patterns - Low Coupling

  • Pattern Name: Low Coupling
  • Solution: Implement an Observer pattern to notify interested parties (e.g., GUI, Logging module) of changes in bank account balances without tightly coupling them to the BankAccount class.
  • Problem: Minimize dependencies between classes to allow for easier maintenance and modification.

GRASP Patterns - Controller

  • Pattern Name: Controller
  • Solution: Assign the responsibility of handling system events or coordinating activities to a controller class.
  • Problem: Determine which class should handle the process of transferring funds between bank accounts.

Learn about GRASP patterns and their applications in software construction. Understand the importance of General Responsibility Assignment Software Patterns in software development.

Make Your Own Quizzes and Flashcards

Convert your notes into interactive study material.

Get started for free

More Quizzes Like This

Grasp the Essence of Islamic Gratitude
6 questions
GRASP Patterns in Object Design
5 questions

GRASP Patterns in Object Design

InestimableRainforest avatar
InestimableRainforest
Use Quizgecko on...
Browser
Browser