GRASP Patterns and Responsibilities
30 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

What does the acronym GRASP stand for?

  • General Responsibility Assignment Software Principles
  • General Responsibility Assignment Software Patterns (correct)
  • General Responsibility Assignment System Patterns
  • General Responsibility Assignment System Principles
  • What is the primary purpose of GRASP patterns?

  • To learn object-oriented programming
  • To create responsibilities for classes
  • To improve software construction
  • To assist in methodical object design (correct)
  • What is a responsibility in UML?

  • A contract or obligation of a classifier (correct)
  • A method of an object
  • A classifier's ability to perform a task
  • A class's attributes
  • What is the relationship between GRASP patterns and object design?

    <p>GRASP patterns help in understanding essential object design</p> Signup and view all the answers

    What is the significance of GRASP patterns?

    <p>They are used to document intuitive knowledge</p> Signup and view all the answers

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

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

    Who created the acronym GRASP?

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

    What is the significance of responsibilities in object design?

    <p>They are related to the obligations of an object</p> Signup and view all the answers

    What is the focus of GRASP patterns?

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

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

    <p>Assignment of responsibilities</p> Signup and view all the answers

    Which GRASP pattern aims to minimize dependencies between classes?

    <p>Low Coupling</p> Signup and view all the answers

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

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

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

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

    What is the primary goal of the Low Coupling pattern?

    <p>Minimizing dependencies between classes</p> Signup and view all the answers

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

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

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

    <p>To notify interested parties of changes in bank account balances</p> Signup and view all the answers

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

    <p>Information Expert</p> Signup and view all the answers

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

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

    What is the primary goal of the High Cohesion pattern?

    <p>Promoting high cohesion</p> Signup and view all the answers

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

    <p>Information Expert</p> Signup and view all the answers

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

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

    What is the purpose of GRASP patterns?

    <p>To provide guidelines for assigning responsibilities to objects</p> Signup and view all the answers

    What is the main idea behind the Information Expert pattern?

    <p>Assigning a responsibility to the class that has the most knowledge</p> Signup and view all the answers

    What is the problem that the Information Expert pattern solves?

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

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

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

    What is the purpose of the Creator pattern?

    <p>To assign the responsibility of creating instances to the class that has the most knowledge</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 name of the GRASP pattern that helps in assigning responsibilities to objects based on the information they have?

    <p>Information Expert</p> Signup and view all the answers

    What is a GRASP pattern?

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

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

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

    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

    Studying That Suits You

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

    Quiz Team

    Related Documents

    Week 12-13 -SWE202.pdf

    Description

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

    More Like This

    Use Quizgecko on...
    Browser
    Browser