140 likes | 226 Views
Advanced Object-Oriented Analysis & Design. Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José State University One Washington Square San José, CA 95192-0180 http://www.engr.sjsu.edu/~fayad. Lesson 8: CRC Cards. 2. Lesson Objectives.
E N D
Advanced Object-Oriented Analysis & Design Dr. M.E. Fayad, Professor Computer Engineering Department, Room #283I College of Engineering San José State University One Washington Square San José, CA 95192-0180 http://www.engr.sjsu.edu/~fayad SJSU -- CmpE
Lesson 8: CRC Cards 2 SJSU – CmpE --- M.E. Fayad
Lesson Objectives • Understand the existing CRC Cards • Understand the problems with existing CRC Cards • Understand and use my CRC Cards • Learn how to create a CRC Cards 3 SJSU – CmpE --- M.E. Fayad
CRC stands for Class, Responsibilities, Collaborations Basic Ideas Create a card for each class Assign responsibilities and attributes to each card Identify collaborations between cards Simulate design scenarios between sets of cards Existing CRC Cards (1) 4 SJSU – CmpE --- M.E. Fayad
Class Name Superclasses Subclasses Responsibilities Collaborators 1. 2. 3. 1. 2. 3. Existing CRC Cards (2) 5 SJSU – CmpE --- M.E. Fayad
Low Cohesion and High Coupling Macho Class Duplicate Functionality No Clear Role is Defined Difficulty in Defining Responsibilities Hard to Map CRC Cards to Class Diagram Major Problems with Existing CRC Cards 6 SJSU – CmpE --- M.E. Fayad
Class (Role) Responsibility Collaboration Client Server Proposed CRC Cards (1) 7 SJSU – CmpE --- M.E. Fayad
Class (Role) Responsibility Collaboration Client Server CRC Cards (2) 1. Define role 2. Provide one, unique responsibility Specify one, unique responsibility within the context that is based on the assigned role Collaborators Services or interfaces that are provided by the named class – no duplicates among classes 9 3. Identify collaborators SJSU – CmpE --- M.E. Fayad
Reduces chances of low cohesion/high coupling by limiting responsibilities Eliminates macho classes as the intelligence is distributed evenly Including services addresses two problems: verifies the validity of the class responsibility ensures that overlapping functionality is avoided Simplifies responsibility definition when a clear role is specified Class Diagram constructs itself The new CRC Cards address many of the stated problems 6 SJSU – CmpE --- M.E. Fayad
CRC Cards (3) Determining a role for each class is useful when defining the class responsibility Example: User- two distinct roles Analyst (modifier) Engineer (viewer) SJSU – CmpE --- M.E. Fayad
CRC Cards (4) SJSU – CmpE --- M.E. Fayad
The collaborations identified in the CRC cards can be used to connect the classes in the class diagram 11 SJSU – CmpE --- M.E. Fayad
What are the good, bad, and ugly about CRC cards? Propose a process of how to use the CRC cards T/F CRC stands for Common Responsible Class CRC cards contains many responsibilities per class. In the CRC cards, collaborators don’t have any relationship with the CRC’s named class. Define: CRC, responsibilities, and collaborators Discussion Questions 13 SJSU – CmpE --- M.E. Fayad
Discuss how to identify objects, classes, attributes, operations, and relationships Questions for the Next Lecture 14 SJSU – CmpE --- M.E. Fayad