Podcast
Questions and Answers
According to the GRASP principle of Information Expert, which class should be responsible for creating instances of a new bank account?
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?
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?
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?
What is the main advantage of using the Observer pattern in the GRASP principle of Low Coupling?
According to the GRASP principle of Information Expert, which class should be responsible for calculating interest on a bank account?
According to the GRASP principle of Information Expert, which class should be responsible for calculating interest on a bank account?
What is the main goal of the High Cohesion GRASP pattern?
What is the main goal of the High Cohesion GRASP pattern?
Which GRASP principle is responsible for determining which class should handle the process of transferring funds between bank accounts?
Which GRASP principle is responsible for determining which class should handle the process of transferring funds between bank accounts?
What is the main benefit of using the GRASP patterns in system design?
What is the main benefit of using the GRASP patterns in system design?
What are the two types of responsibilities of an object?
What are the two types of responsibilities of an object?
What does the 'doing' responsibility of an object include?
What does the 'doing' responsibility of an object include?
What is the primary purpose of GRASP patterns?
What is the primary purpose of GRASP patterns?
What is the problem solved by the Information Expert pattern?
What is the problem solved by the Information Expert pattern?
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?
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?
What is a characteristic of a GRASP pattern?
What is a characteristic of a GRASP pattern?
What is an example of a 'knowing' responsibility of an object?
What is an example of a 'knowing' responsibility of an object?
How many GRASP patterns are there?
How many GRASP patterns are there?
What is the primary purpose of GRASP patterns?
What is the primary purpose of GRASP patterns?
What is the relationship between responsibilities and behavior in an object?
What is the relationship between responsibilities and behavior in an object?
Who is credited with creating the GRASP acronym?
Who is credited with creating the GRASP acronym?
What is the focus of the four GRASP patterns to be presented?
What is the focus of the four GRASP patterns to be presented?
What is the quote about the most likely way for the world to be destroyed?
What is the quote about the most likely way for the world to be destroyed?
What is the definition of a responsibility in UML?
What is the definition of a responsibility in UML?
What is the primary goal of GRASP patterns in software design?
What is the primary goal of GRASP patterns in software design?
What is the significance of GRASP patterns in object design?
What is the significance of GRASP patterns in object design?
Flashcards are hidden until you start studying
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.