Gordon CPS 211 - Identifying Responsibilities; CRC Cards

Unformatted text preview:

CS211 Lecture: Identifying Responsibilities; CRC Cardslast revised September 17, 2007Objectives:1. To show how to use CRC cards to identify objects and find responsibilities Materials:1. ATM System example on the web.2. Session Use Case flow of events handout3. Supply of 3x5 cards for CRC cardsI. IntroductionA. Preliminary notes:1. We will not go over the two quick-check questions in class2. Turn in class diagram questions in writingB. As we pointed out at the start of the course, there are many different processes that can be followed in software development (e.g. waterfall life cycle, RUP, etc).C. Regardless of what process is followed, however, certain tasks will need to be done as part of the development process per se - whether all at once, iteratively, or incrementally. In fact, activities like these will be part of any situation in which one uses his/her professional skills to help solve someone else’s problem - not just when creating software or even in a computer field.1. Establishing Requirements: The goal of this is to spell out what constitutes a satisfactory solution to the problem.2. Analysis. The goal of this is to understand the problem.3. Design. The goal of this is to develop the overall structure of a solution to the problem in terms of individual, buildable components and their relationships to one another.4. Implementation. The goal of this task is to actually build the system as designed.5. Installation / Maintenance / Retirement1D. The approach that we are taking to design is called a use-case driven approach , because we use the use cases identified during analysis to drive the design process. Our approach is as follows1. Develop the class structure for the systema) Identify the classes that need to be part of the system - a topic we dealt with some time ago. We saw then that there are two things we can consider when seeking to identify classes(1) The problem domain(2) Key nouns that occur in the use casesb) Identify the relationships between various classes - a topic we have been dealing with.c) Assign responsibilities to each class. Each responsibility that must be fulfilled to accomplish the use cases must be assigned to some class. This will be the focus of this set of lectures.2. In a subsequent set of lectures, we will deal with the process of detailed design of the various classes3. Since large systems may include hundreds or thousands of classes, some partitioning of classes into subsystems (packages) is often necessary. This is a portion of the design process we will not discuss until later, though.E. As we do the design, we will often discover the need for additional objects and classes, to facilitate the implementation of the objects we discovered during analysis. (Booch et. al. observe that there may be a 5:1 ratio between classes discovered at analysis time and classes ultimately needed to implement a system.)II. Assigning Responsibilities to Classes: CRC CardsA. Once we have some notion of the key classes that the objects comprising the system will belong to, we can begin determining what responsibilities each class will fulfill.B. One tool that we can use to help us do this is called CRC Cards (CLASS, RESPONSIBILITY, COLLABORATOR). CRC cards are not a formal part of UML, but are commonly used as a vehicle for doing design that is then documented using UML diagrams.21. A CRC card is a card (generally about 3 x 5) containing at the top the name of a class, followed by two parallel lists.a) The list on the left hand side lists the responsibilities of the class.b) The list on the right hand side lists the other classes (if any) with which this class must collaborate to carry out each task.2. To get started, we can create a CRC card for each of the classes we discovered during the analysis phase. As we discover the need for additional classes, we can create additional CRC cards.EXAMPLE: We will develop a partial set of CRC cards for the ATM example in class. For the portion we are doing, we will need cards for the following classes:a) ATMb) Sessionc) Transactiond) CardReadere) CustomerConsolef) CardDRAW CARDS ON BOARD3. A typical way to use CRC cards is to "walk through" the various use cases, identifying tasks that need to be performed and assigning the responsibility for each to an appropriate class, by recording it in the “responsibility” column of the appropriate card.a) The use case itself is made a responsibility of some class.b) The classes that are called upon to perform specific responsibilities as part of the use case become collaborators, noted in the “Collaborators” column of the card for the class that is responsible for the use case.c) In addition, each collaborator class gets one or more responsibilities listed in the “Responsibilities” column of its card - which may in turn, lead to identifying further collaborators it needs, etc.4. The key question to ask for each operation we find in the use cases is "what class should be responsible for this?" Often there will be more than one possible answer, so the different alternatives need to be examined carefully before a choice is made.35. This process lends itself particularly well to a group of people working together, with individual members of the group role-playing various classes. (Remember, in an OO system the basic computational model is one of different objects sending messages to each other. We represent this by having the person who is role playing a class that needs some task perform asking the representative of an appropriate collaborating class to perform it.)C. We will do an example of this process shortly. Before doing so, let’s do an exercise from the book to become familiar with what a CRC card looks like.Do Exercise 6.11. Small groups2. Discuss as class3. What additional classes would get responsibilities on their CRC cards as a result of assigning collaborators on “Mother”?ASKD. EXAMPLE: Walk through session use case.Ask several students to role play the various classes. Fill in CRC cards on board as classes get responsibilities or collaborators. NOTE AT OUTSET: There is no one best way to make the responsibility assignments. I made certain choices in developing the example, and we will work with those so that everything hangs together.1. The use case flow of events for this case begins “A session is started when a customer inserts an ATM card into the card reader slot of the machine ..."a) An obvious assignment of


View Full Document

Gordon CPS 211 - Identifying Responsibilities; CRC Cards

Download Identifying Responsibilities; CRC Cards
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Identifying Responsibilities; CRC Cards and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Identifying Responsibilities; CRC Cards 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?