1 / 25

IS514 Lecture Week 9

IS514 Lecture Week 9. CRC Cards. So far. Behaviour model Use Case Diagrams Use Case Descriptions Structural Model Class Diagrams This week Continue with Behavioural Model Class Responsibility Collaboration Cards. Background. Created by Tektronix, in Portland, Oregon (1989)

ursula
Download Presentation

IS514 Lecture Week 9

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IS514 Lecture Week 9 CRC Cards

  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. 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 http://c2.com/doc/oopsla89/paper.html

  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. 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. 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. Example Simple CRC card Quick exercise – What have I missed? What other responsibilities and collaborators are there?

  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. Exercise 1 – One Possible Answer

  10. Exercise 1 – One Possible Answer

  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. 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. 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. 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. 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. 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. 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. 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. 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. Exercise 2 – One possible answer

  21. Exercise 2 – One possible answer

  22. Exercise 2 – One possible answer

  23. Exercise 2 – One possible answer

  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 213-215) Further reading Bennett, S., McRobb, S. and Farmer, R. (2002) Object-Oriented Systems Analysis and Design using UML, 2nd Edition, McGraw-Hill Pages 168-176 • http://c2.com/doc/oopsla89/paper.html • http://www.math-cs.gordon.edu/courses/cs211/ATMExample/CRCCards.html

  25. Summary • What CRC cards are • How to use CRC cards

More Related