SWE202: GRASP Patterns in Software Construction
24 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

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

  • Bank (correct)
  • BankAccount
  • AccountManager
  • TransactionController
  • What is the main goal of the Low Coupling GRASP pattern?

  • To promote high cohesion
  • To reduce system events
  • To minimize dependencies between classes (correct)
  • To increase dependencies between classes
  • Which GRASP principle is responsible for assigning the responsibility of handling system events or coordinating activities to a controller class?

  • Information Expert
  • Low Coupling
  • High Cohesion
  • Controller (correct)
  • What is the main advantage of using the Observer pattern in the GRASP principle of Low Coupling?

    <p>To notify interested parties of changes in bank account balances without tightly coupling them to the BankAccount class</p> Signup and view all the answers

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

    <p>BankAccount</p> Signup and view all the answers

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

    <p>To assign a responsibility to the class that has the necessary information to fulfill it</p> Signup and view all the answers

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

    <p>Controller</p> Signup and view all the answers

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

    <p>To facilitate easier maintenance and flexibility in the system</p> Signup and view all the answers

    What are the two types of responsibilities of an object?

    <p>Knowing and Doing</p> Signup and view all the answers

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

    <p>Initiating action in other objects</p> Signup and view all the answers

    What is the primary purpose of GRASP patterns?

    <p>To assign responsibilities to objects</p> Signup and view all the answers

    What is the problem solved by the Information Expert pattern?

    <p>What is a basic principle by which to assign responsibilities to objects?</p> Signup and view all the answers

    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?

    <p>Creator</p> Signup and view all the answers

    What is a characteristic of a GRASP pattern?

    <p>It is a named problem/solution pair that can be applied in new contexts</p> Signup and view all the answers

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

    <p>Knowing about private encapsulated data</p> Signup and view all the answers

    How many GRASP patterns are there?

    <p>9</p> Signup and view all the answers

    What is the primary purpose of GRASP patterns?

    <p>To develop a methodical approach to object design</p> Signup and view all the answers

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

    <p>Responsibilities are related to an object's behavior in terms of its obligations</p> Signup and view all the answers

    Who is credited with creating the GRASP acronym?

    <p>Craig Larman</p> Signup and view all the answers

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

    <p>Assigning responsibilities to classes</p> Signup and view all the answers

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

    <p>By accident</p> Signup and view all the answers

    What is the definition of a responsibility in UML?

    <p>A contract or obligation of a classifier</p> Signup and view all the answers

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

    <p>To help understand essential object design</p> Signup and view all the answers

    What is the significance of GRASP patterns in object design?

    <p>They are creative steps in the design process</p> Signup and view all the answers

    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.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Description

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

    More Like This

    Use Quizgecko on...
    Browser
    Browser