Presentation is loading. Please wait.

Presentation is loading. Please wait.

An informal, team oriented, OO design system

Similar presentations


Presentation on theme: "An informal, team oriented, OO design system"— Presentation transcript:

1 An informal, team oriented, OO design system
CRC Cards An informal, team oriented, OO design system Copyright © 2016 by Curt Hill

2 Copyright © 2016 by Curt Hill
Briefly Stands for Class, Responsibilities, and Collaboration Originally a teaching tool for objects Kent Beck and Ward Cunningham (1989) Now also an informal OO design technique Format is name at top Responsibilities on left Collaborating classes on right Super and sub classes are sometimes present Copyright © 2016 by Curt Hill

3 Copyright © 2016 by Curt Hill
Example Format Copyright © 2016 by Curt Hill

4 Copyright © 2016 by Curt Hill
Creating and Using Consider the scenario or user story Find classes within this scenario Find responsibilities and properties Define collaborators Move the cards around Simulate scenarios using the cards Copyright © 2016 by Curt Hill

5 Copyright © 2016 by Curt Hill
Find Classes An analysis task Identifies the building blocks of application Look for verbs and nouns A good rule of thumb is to look for the three to five main classes Later add classes concerning User interface Storage Or other helpers for the main classes Copyright © 2016 by Curt Hill

6 Copyright © 2016 by Curt Hill
Responsibilities What does the class do? These will become methods What does the class need to do this? These may become properties A responsibility for a class may fulfill the need of another class Copyright © 2016 by Curt Hill

7 Copyright © 2016 by Curt Hill
Find Collaborators A class often does not have sufficient information to fulfill its responsibilities It must then collaborate with other classes Collaboration will be in one of two forms: A request for information A request to perform a task Copyright © 2016 by Curt Hill

8 Identifying Collaborators
Ask some questions Does the class have the ability to fulfill this responsibility? If not, then look for a class that either has the ability or a class which should have the ability This will show the need for new responsibilities in other classes or the need for new classes Copyright © 2016 by Curt Hill

9 Copyright © 2016 by Curt Hill
Collaborations Typically one way relationship A client server relationship Client class asks server class to: Perform a service Return some information Very seldom does the server turn around and ask the client something Copyright © 2016 by Curt Hill

10 Copyright © 2016 by Curt Hill
Move the Cards Around Place cards on a table Two cards that collaborate should be close together Is a and has a relationship should be close as well Two cards that don't collaborate should be placed far apart The more two cards collaborate, the closer they should be This makes it easier to understand the relationships between classes Copyright © 2016 by Curt Hill

11 Copyright © 2016 by Curt Hill
The Session Start with a user story or scenario Use the cards to simulate how such a system would work This is a group activity There should be at least: A domain expert An experienced OO designer Developers A group leader Copyright © 2016 by Curt Hill

12 Copyright © 2016 by Curt Hill
Example Suppose we want to simulate a library We will have several scenarios: Checking out a book Returning a book Search for a book Copyright © 2016 by Curt Hill

13 Copyright © 2016 by Curt Hill
Finding classes A brainstorming exercise produced the following candidates: Library, Librarian, User, Borrower, Article, Material, Item, Due Date, Fine, Lendable, Book, Video and Journal These were refined into a smaller set: Librarian, User, Borrower, Lendable, Book, Video and Journal Next a card for each Copyright © 2016 by Curt Hill

14 Copyright © 2016 by Curt Hill
Scenario Questions Who should have the overall responsibility of check-out? Librarian What sub-tasks are part of this task? Checking the borrower Assigning a due date Moving the book from in to out status Connecting book with borrower Copyright © 2016 by Curt Hill

15 Copyright © 2016 by Curt Hill
Simulate The check out scenario is now simulated In the simulation responsibilities and collaborators are identified Assign attributes to fulfill the responsibilities In our example the following CRC cards were produced Copyright © 2016 by Curt Hill

16 Copyright © 2016 by Curt Hill
Results of CRC Cards Librarian Borrower Check out book for borrower Book Borrower Can borrow Know set of books Book Book Date Know if overdue Check out Calculate due date In or out Know due date Know borrower Date Compare dates Date Copyright © 2016 by Curt Hill

17 Copyright © 2016 by Curt Hill
Continuing After this scenario is done work through the next scenarios This may cause the cards (classes) to change or others to be added For example a search would require a set of books None of these classes could as yet handle this Copyright © 2016 by Curt Hill

18 Copyright © 2016 by Curt Hill
Good Practices Start with simplest scenarios Use meaningful class names You may be stuck with them Write a description of the class Usually after end of scenario Before that it may not last If in doubt, then act it out Be flexible Copyright © 2016 by Curt Hill

19 Copyright © 2016 by Curt Hill
Aftermath When we are done the information needs to be saved Complete set of cards The cards may be incomplete during simulations They should be fully completed now Optionally: Collaboration diagram Copyright © 2016 by Curt Hill

20 Copyright © 2016 by Curt Hill
Actual Classes Once the design is complete we can get to implementation New helper classes may be created at this point Design classes may be split into multiple classes Neither of these suggests that there were flaws in the design Copyright © 2016 by Curt Hill

21 Copyright © 2016 by Curt Hill
Finally CRC cards are frequently used in the design phase This is a team activity Once the basic design is done implementation is comparatively easy Are we ready for an exercise? Finally for now Copyright © 2016 by Curt Hill


Download ppt "An informal, team oriented, OO design system"

Similar presentations


Ads by Google