Presentation is loading. Please wait.

Presentation is loading. Please wait.

SWE 4743 Responsibility Driven Design with CRC cards Richard Gesick.

Similar presentations


Presentation on theme: "SWE 4743 Responsibility Driven Design with CRC cards Richard Gesick."— Presentation transcript:

1 SWE 4743 Responsibility Driven Design with CRC cards Richard Gesick

2 SWE 4743 2- 18 Analysis (or requirements analysis) involves studying the problem to be solved. It identifies what the problem is without addressing how it will be solved. Design is the creative process that transforms a problem into a solution. It identifies how the problem will be solved.

3 SWE 4743 3- 18 The boundaries between analysis and design are fuzzy, although the focus of each is quite distinct. In analysis, we seek to model the world by discovering the classes and objects that form the vocabulary of the problem domain, in design, we invent the abstractions and mechanisms that provide the behavior that this model requires.

4 SWE 4743 4- 18 IDENTIFYING CLASSES AND OBJECTS Write an English description of the problem and underline the nouns and verbs. Consider the nouns as candidate objects. Consider the verbs as candidate operations upon the objects

5 SWE 4743 5- 18 RESPONSIBILITY-DRIVEN DESIGN Design technique driven by the delegation of responsibilities Goal -- To focus on building a model of interacting objects before filling out precise details of each class Involves reducing data & control dependencies between modules (information hiding) and designing reusable code

6 SWE 4743 6- 18 Philosophy -- No action can take place without an agent (object) performing the action. Central focus of OOD -- establishing WHO is responsible for each action

7 SWE 4743 7- 18 CRC cards: CRC cards: Class, Responsibility, & Collaboration An object’s responsibilities are high-level statements about the knowledge it maintains and the operations it supports A collaboration is a request made by one object to another

8 SWE 4743 8- 18 Each class = a CRC card class name _______________________________ [subclass: ] [superclass: ] responsibilities|collaborators |

9 SWE 4743 9- 18 CRC Elements Class:Choose meaningful names (they influence the design) Responsibilities: Describe the problem to be solved Use short verb phrases Show WHAT is to be done and not HOW it is to be done View them as a contract They should fit on the card -- may require moving responsibilities or dividing the task

10 SWE 4743 10- 18 CRC Elements Collaborators: All classes of which the class needs to be aware MUST include all classes that provide services MAY include classes that require services provided by this class

11 SWE 4743 11- 18 Types of classes Data managers, data, or state classes: – Responsibility-- to maintain data or state information – The NOUNS in the problem description – The fundamental building blocks of the design Data sinks or data sources: – Classes that GENERATE data or ACCEPT data and then PROCESS them further – They don't hold the data for a period of time

12 SWE 4743 12- 18 Types of classes View or observer classes: – Classes used to display information – Display behavior is isolated in separate classes from those classes that maintain the data being displayed – The actual base data is called the MODEL and the display class is called the VIEW – One model may have more than one view

13 SWE 4743 13- 18 Types of classes Facilitator or helper classes: – These classes maintain little or no state information themselves – They assist in the execution of complex tasks

14 SWE 4743 14- 18 DESIGN PROCESS: Discover classes and define what responsibilities are assigned to each class –Start from obvious classes and progress to the unknown by simulating SCENARIOS –Assign each action as a responsibility to a specific object (place on a crc card) –Different scenarios generate more responsibilities. –Task becomes one of developing a CLEAR DESCRIPTION and an UNDERSTANDING of each component of the system.

15 SWE 4743 15- 18 DESIGN PROCESS: Decide HOW those responsibilities are to be achieved –Any value accessed or modified widely or that exists for a significant period of time should be MANAGED; (one class has responsibility for the actions taken to view or modify the data) –Add the data values managed by the class (hidden data) to the back of the crc card

16 SWE 4743 16- 18 DESIGN PROCESS: Discover relationships between classes to identify responsibilities : –Find IS-KIND-OF relationships to facilitate reuse -- If a class is a kind of another class, it is an IS-A relationship. This allows you to assign responsiblities to the superclass. –Find IS-ANALOGOUS-TO relationships -- If two or more classes have some of the same responsibilities, it is usually a sign that they share a superclass. –Find IS-PART-OF relationships -- Identifying a clear distinction between whole and part helps to determine where responsibilities should be.

17 SWE 4743 17- 18 DESIGN PROCESS:. Discover relationships between classes to identify collaborations : –Find IS-PART-OF relationships -- Whole-part relationships come in two types: –Composite class and the objects that compose it -- The composite class is responsible for knowing about its parts (i.e., a collaboration); (e.g., a car must collaborate with its part steering wheel, which turns the wheels, in order to fulfill its responsibility of turning) –Container class and its elements -- May or may not require a collaboration, depends on the domain. (e.g., arrays contain elements but do not need to send messages to them)

18 SWE 4743 18- 18 DESIGN PROCESS: –Find HAS-KNOWLEDGE-OF relationships -- Implies there is a responsibility to know information. One class knows about another class because it needs to get information from that class. –Find DEPENDS-UPON relationships -- Usually indicated in the specification by “changes with” implying a connection between classes. (e.g., a drawing changes with the addition of drawing elements; the drawing depends upon the structure of the drawing elements)


Download ppt "SWE 4743 Responsibility Driven Design with CRC cards Richard Gesick."

Similar presentations


Ads by Google