Lecture 10 - GRASP Flashcards
What is the focus of object design?
Identify classes and objects, decide what methods belong were, and how these objects should interact
What are responsibilities regarding objects?
Obligation of an object in terms of behaviour
What are the two types of responsibilities regarding objects?
- Doing
- Knowing
What does the Doing responsibility do regarding objects? (3)
- Doing something (i.e. creating object, doing calculation)
- Initiating action in other objects
- Controlling + coordinating activities in other objects
What does Knowing responsibility do regarding objects? (3)
- Knowing about private encapsulated data
- Knowing about related objects
- Knowing about things it can derive or calculate
When are responsibilities assigned to classes?
During object design
“A sale is responsible for creating a SalesLineItems” is an example of…
the Doing responsibility
“A sale is responsible for knowing its total” is an example of…
the Knowing responsibility
TF: Responsibilities related to “Knowing” are often inferable from the Domain Model
True. Because of attributes and associations illustrated in it
The translation of responsibilities into classes and methods is influenced by what?
Granularity of responsibility
TF: Responsibility is the same thing as a method
False. Methods are implemented to fulfill responsibilities, but they are not the same thing
Within UML artifacts, what is a common context in which responsibilities are considered?
During the creating of Interaction Diagrams
What do Patterns guide?
Guide choices in where to assign responsibilities
What is a named description of a problem and a solution that can be applied to new contexts?
Patterns
TF: A pattern provides advice in how to apply a solution to a problem in varying circumstances
True
What is the basic idea of Information Expert?
To assign a responsibility to the object (class) that has the most information necessary to fulfill it
Fulfillment of a responsibility often requires information spread across different classes, what can the other classes be known as?
Partial experts
The class responsible for creating instances of another class is called a…
Creator
What conditions does a class ‘A’ need to satisfy to be considered a Creator for class ‘B’? (4)
- A aggregates B objects
- A contains B objects
- A records instances of B objects
- A has the initializing data that will be passed when B is created
What is the problem with Solution by Expert?
Can sacrifice high cohesion and low coupling