Professional Documents
Culture Documents
Unit 2: Use Case Analysis: Module 3: Class Responsibility Collaboration Cards
Unit 2: Use Case Analysis: Module 3: Class Responsibility Collaboration Cards
Unit 2: Use Case Analysis: Module 3: Class Responsibility Collaboration Cards
Behavior-driven approach:
◦ Populates a class first with the operations that the class will
perform, and determines from those operations the data that
should be owned by the class.
◦ How do you know that the operation belongs with the correct
class? There is no clear way of knowing.
…Confirming Candidate Classes
Responsibility-driven approach:
◦ Starts with a large-grained view of the class and first
assigns responsibilities to that class.
◦ This approach describes first the "mission" statement of
a class in the context of the problem domain in which we
are working.
This mission statement is a declaration of the services the
class will provide to requestors of those services.
◦ In military terms, the responsibilities are strategic; the
operations and data are tactical (subservient to, and a
means of achieving, the strategy).
The operations and attributes provide a means to
achieving the requested responsibilities.
What is a Responsibility?
Responsibility: is a contract or
obligation of the class and later
translates into operations and
attributes as models are refined.
…What is a Responsibility?
When you create a class, you are
making a statement that all objects
of that class should have the same
responsibilities that is realized
through operations and attributes.
This means the responsibilities of a
create()
save()
Operations
delete()
change()
Describing Class Responsibilities
Each analysis class may have several
responsibilities
◦ A class with only one responsibility is probably too simple.
◦ A class with a dozen or more is pushing the limit of
reasonability and should potentially be split into several
classes.
◦ Responsibilities can evolve into one (but usually more)
operations on classes in design.
Ambler, S. W. (n.d.). Class Responsibility Collaborator (CRC) Models. Retrieved September 19, 2011, from Agile
Modeling: http://www.agilemodeling.com/artifacts/crcModel.htm
…Finding Responsibilities
To find responsibilities:
◦ Ask yourself what the class does, and
◦ What information do you wish to maintain about the class.
Note: You will often identify a responsibility for a class to
fulfill a collaboration with another class.
create()
Operations save() Does
delete()
change()
Ambler, S. W. (n.d.). Class Responsibility Collaborator (CRC) Models. Retrieved September 19, 2011, from Agile
Modeling: http://www.agilemodeling.com/artifacts/crcModel.htm
Collaborations
Sometimes a class has a responsibility to
fulfill, but not enough information to do so.
◦ For example, a student enroll in a course. To do this, a
student needs to know if a spot is available in the
course and, if so, he then needs to be added to the
course.
◦ However, the student class only have information
about themselves (their names and so forth), and not
about a course.
◦ What the student class needs to do is
collaborate/interact with the Course class to sign up for
a course.
Ambler, S. W. (n.d.). Class Responsibility Collaborator (CRC) Models. Retrieved September 19, 2011, from Agile
Modeling: http://www.agilemodeling.com/artifacts/crcModel.htm
…Collaborations
Collaboration takes one of two forms:
◦ A request for information
For example, the Student requests an indication from the
Course class whether a space is available.
◦ A request to do something.
The Student then requests to be added to the Course class, a
request to do something.
Ambler, S. W. (n.d.). Class Responsibility Collaborator (CRC) Models. Retrieved September 19, 2011, from Agile
Modeling: http://www.agilemodeling.com/artifacts/crcModel.htm
Class Responsibilities
Recap:
◦ A responsibility is anything that a class Knows, or
For example, students have a student number, first name,
surname. These are the things a student class knows about a
student.
◦ A responsibility is anything that a class Does.
For example, the student class allows the system to create new
student. These are the things a student class does respectively.
Class Responsibility Collaboration Card
Student Class
RESPONSIBILITY COLLABORATION
Knows Student No
Knows First Name
Knows Surname
Add a Student
Ambler, S. W. (n.d.). Class Responsibility Collaborator (CRC) Models. Retrieved September 19, 2011, from Agile
Modeling: http://www.agilemodeling.com/artifacts/crcModel.htm
Class Collaborations
Collaboration takes one of two forms:
◦ A request for information, or
For example, a Student may request information from the Course class
◦ A request to do something.
For example, a student enroll into a course. To do this, a student needs
to know if a spot is available in the course and, if so, he then needs to
be added to the course.
What the student needs to do is collaborate/interact with the Course
class to sign up for a course.
Therefore, Course is included in the list of collaborators of the Student
class.
Class Responsibility Collaboration Card
Student Class
RESPONSIBILITY COLLABORATION
Knows Student No
Create a Student
Enrols into a Course Course
Ambler, S. W. (n.d.). Class Responsibility Collaborator (CRC) Models. Retrieved September 19, 2011, from Agile
Modeling: http://www.agilemodeling.com/artifacts/crcModel.htm
Review
What is the difference between the three approaches to
confirming classes?
What is a Responsibility?
What should you look for when finding responsibilities?
What is a Collaboration?
What forms can a Collaboration take on?
How do you know that a responsibility should have a
collaboration with another class?