Presentation is loading. Please wait.

Presentation is loading. Please wait.

IS514Slide 1 IS514 Lecture Week 9 CRC Cards. IS514Slide 2 So far Behaviour model –Use Case Diagrams –Use Case Descriptions Structural Model –Class Diagrams.

Similar presentations


Presentation on theme: "IS514Slide 1 IS514 Lecture Week 9 CRC Cards. IS514Slide 2 So far Behaviour model –Use Case Diagrams –Use Case Descriptions Structural Model –Class Diagrams."— Presentation transcript:

1 IS514Slide 1 IS514 Lecture Week 9 CRC Cards

2 IS514Slide 2 So far Behaviour model –Use Case Diagrams –Use Case Descriptions Structural Model –Class Diagrams This week –Continue with Behavioural Model –Class Responsibility Collaboration Cards

3 IS514Slide 3 Background Created by Tektronix, in Portland, Oregon (1989) Large users of Smalltalk Attributed with the development of several key ideas in object technology Ward Cunningham and Kent Beck Presented as a technique to help ‘think objects’ NOT part of UML

4 IS514Slide 4 Responsibilities and Collaborations Responsibilities –Knowing –Doing Collaboration –Objects working together to service a request Object oriented systems are made up of objects working together to provide functionality CRC cards can help to form a “bridge” from structural model to behavioral model

5 IS514Slide 5 The essentials of CRC cards Anthropomorphism Pretending classes have human characteristics Extremely simple technique Rather than use diagrams to develop models use 4 x 6 index cards Rather than indicate attributes and operations on the cards, they identify responsibilities and collaborators Two uses: –Examining domain –Based upon use cases and use case descriptions from the domain

6 IS514Slide 6 CRC Cards On the index card, record the following information:- –the name of the class, at the top –the responsibilities of the class, on the left-hand side –the collaborators of the class, which help to carry out each responsibility, on the right-hand side of the card Many templates exist (see Dennis for another)

7 IS514Slide 7 Example Simple CRC card Student ResponsibilityCollaborators Complete AssessmentAssessment Submit AssessmentSchool office Attend LectureLecture Attend SeminarSeminar Quick exercise – What have I missed? What other responsibilities and collaborators are there?

8 IS514Slide 8 Exercise 1 Consider a public house. Consider two classes in the public house. Think about the working of a pub and the interactions between –Bar person –Customer Draw CRC cards for these two classes This may involve you identifying other classes This should take about 10 minutes

9 IS514Slide 9 Exercise 1 – One Possible Answer Bar Person ResponsibilityCollaborators Take orders from customersOrder Customer Serve ordersOrder Product Take payments and give changeTill Check stockStock

10 IS514Slide 10 Exercise 1 – One Possible Answer Customer ResponsibilityCollaborators Given ordersBar Person Order Receive ordersBar Person Order Product Make paymentsBar Person

11 IS514Slide 11 What have we seen Identification of “new” classes –Order –Product –Till –Stock How classes interact to provide functionality A feel for behavioural aspects of the system Each of these would also need a CRC card

12 IS514Slide 12 CRC Card Responsibilities The responsibilities of the class describe at a high-level the purpose of the class’s existence They are connected to the operations the class provides, but are more general than that might imply : –e.g. in a library system “Make Payment” is acceptable as a description of a responsibility there may well be many associated operations

13 IS514Slide 13 Coupling & Cohesion A criteria for Good Analysis / Design Coupling –Degree of Interconnectedness –Number of links & degree of interaction Cohesion –Contribution to single purpose Not mutually exclusive

14 IS514Slide 14 CRC Good Practice If a class has lots of responsibilities :- –Can describe them more concisely, and, if not –Would be better to split the responsibilities and have two or more classes Too many responsibilities: –Bad- low cohesion Too many collaborators: –Bad -high coupling Using CRC cards should help to identify and fix both these faults in a model

15 IS514Slide 15 Why use CRC cards At the start, you may not know which other classes a class has to collaborate with in order to fulfill a responsibility Using CRC cards facilitate this If an object of one class collaborates with an object of another class, it does so by using operations of the other –A class has a relationship with each of it’s collaborators Using CRC cards is helps to establish in which direction associations should be navigable

16 IS514Slide 16 Class Diagrams – navigable relationships So far all relationships in class diagrams and use cases have been navigable in two ways This is not always the case Officer is investigating a crime Crime doesn’t know which officer is investigating it or indeed if it is being investigated!

17 IS514Slide 17 CRC cards in practice (1 of 2) One of the main benefits of CRC cards is that they encourage animated discussion among developers Especially effective when walking through a Use Case to see how the classes are going to implement it (using role play) –We will see an example of this in the seminars –Anthropomorphism Developers pick cards as each class collaborates in the Use Case As ideas about responsibilities are formed the cards are annotated

18 IS514Slide 18 CRC cards in practice (2 of 2) Stops thinking about classes as dumb data holders and moves thinking towards understanding the higher-level behavior of each class CRC cards work on ‘object’ communication (not classes) Can provide a draft class model Apart from the technical benefits, stimulates –Team discussion and hence team spirit Technique suitable for highlighting opportunities to refactor the class model Refactoring is the process of altering the class model of an object- oriented design without altering it’s visible behavior

19 IS514Slide 19 Exercise 2 – Have another go Consider a Library. A library has Borrowers, Books Copies of Books and Reservations. Borrowers can borrow copies of books and make reservations. Draw CRC cards for the library Hint classes: –Borrower –Book –Copy –Reservation

20 IS514Slide 20 Exercise 2 – One possible answer Borrower ResponsibilityCollaborators Borrows booksBook Copy Return booksBook Copy Make reservationsBook Reservation

21 IS514Slide 21 Exercise 2 – One possible answer Book ResponsibilityCollaborators To have copiesCopy To be borrowedBorrower Copy To be reservedReservation Borrower Copy

22 IS514Slide 22 Exercise 2 – One possible answer Copy ResponsibilityCollaborators Provides book infoBook Provides borrower infoBorrower Provides reservation infoReservation

23 IS514Slide 23 Exercise 2 – One possible answer Reservation ResponsibilityCollaborators To create a reservation for a book Book Borrower To hold copyCopy Book

24 IS514Slide 24 This weeks reading ESSENTIAL READING Dennis A, Wixom B, and Tegarden D (2005) System Analysis and Design with UML version 2 second edition, Wiley Chapter 7 ( especially ) Further reading Bennett, S., McRobb, S. and Farmer, R. (2002) Object- Oriented Systems Analysis and Design using UML, 2nd Edition, McGraw-Hill Pages cs.gordon.edu/courses/cs211/ATMExample/CRCCards.htmlhttp://www.math- cs.gordon.edu/courses/cs211/ATMExample/CRCCards.html

25 IS514Slide 25 Summary What CRC cards are How to use CRC cards


Download ppt "IS514Slide 1 IS514 Lecture Week 9 CRC Cards. IS514Slide 2 So far Behaviour model –Use Case Diagrams –Use Case Descriptions Structural Model –Class Diagrams."

Similar presentations


Ads by Google