Podcast
Questions and Answers
What does the acronym GRASP stand for?
What does the acronym GRASP stand for?
What is the primary purpose of GRASP patterns?
What is the primary purpose of GRASP patterns?
What is a responsibility in UML?
What is a responsibility in UML?
What is the relationship between GRASP patterns and object design?
What is the relationship between GRASP patterns and object design?
Signup and view all the answers
What is the significance of GRASP patterns?
What is the significance of GRASP patterns?
Signup and view all the answers
According to the quote, what is the most likely way for the world to be destroyed?
According to the quote, what is the most likely way for the world to be destroyed?
Signup and view all the answers
Who created the acronym GRASP?
Who created the acronym GRASP?
Signup and view all the answers
What is the significance of responsibilities in object design?
What is the significance of responsibilities in object design?
Signup and view all the answers
What is the focus of GRASP patterns?
What is the focus of GRASP patterns?
Signup and view all the answers
What is the creative step during design, according to GRASP?
What is the creative step during design, according to GRASP?
Signup and view all the answers
Which GRASP pattern aims to minimize dependencies between classes?
Which GRASP pattern aims to minimize dependencies between classes?
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?
According to the Information Expert pattern, which class should be responsible for creating instances of a new bank account?
Signup and view all the answers
Which GRASP pattern is related to handling system events or coordinating activities?
Which GRASP pattern is related to handling system events or coordinating activities?
Signup and view all the answers
What is the primary goal of the Low Coupling pattern?
What is the primary goal of the Low Coupling pattern?
Signup and view all the answers
Which class should be responsible for calculating interest on a bank account according to the Information Expert pattern?
Which class should be responsible for calculating interest on a bank account according to the Information Expert pattern?
Signup and view all the answers
What is the purpose of the Observer pattern in the Low Coupling pattern?
What is the purpose of the Observer pattern in the Low Coupling pattern?
Signup and view all the answers
Which GRASP pattern is related to assigning responsibilities to classes that have the necessary information?
Which GRASP pattern is related to assigning responsibilities to classes that have the necessary information?
Signup and view all the answers
Which class should be responsible for transferring funds between bank accounts according to the Controller pattern?
Which class should be responsible for transferring funds between bank accounts according to the Controller pattern?
Signup and view all the answers
What is the primary goal of the High Cohesion pattern?
What is the primary goal of the High Cohesion pattern?
Signup and view all the answers
Which GRASP pattern aims to promote high cohesion by assigning responsibilities to classes that have the necessary information?
Which GRASP pattern aims to promote high cohesion by assigning responsibilities to classes that have the necessary information?
Signup and view all the answers
What is the primary focus of 'doing' responsibilities in an object?
What is the primary focus of 'doing' responsibilities in an object?
Signup and view all the answers
What is the purpose of GRASP patterns?
What is the purpose of GRASP patterns?
Signup and view all the answers
What is the main idea behind the Information Expert pattern?
What is the main idea behind the Information Expert pattern?
Signup and view all the answers
What is the problem that the Information Expert pattern solves?
What is the problem that the Information Expert pattern solves?
Signup and view all the answers
What is the main characteristic of a 'knowing' responsibility?
What is the main characteristic of a 'knowing' responsibility?
Signup and view all the answers
What is the purpose of the Creator pattern?
What is the purpose of the Creator pattern?
Signup and view all the answers
How many GRASP patterns are there?
How many GRASP patterns are there?
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?
What is the name of the GRASP pattern that helps in assigning responsibilities to objects based on the information they have?
Signup and view all the answers
What is a GRASP pattern?
What is a GRASP pattern?
Signup and view all the answers
Which of the following is NOT a type of responsibility in an object?
Which of the following is NOT a type of responsibility in an object?
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.
Related Documents
Description
Learn about GRASP, a methodical approach to object-oriented design, and understand responsibilities in classes, including the two types: doing and knowing.