Drexel University
CS 451 Software Engineering
1
CS 451 Software Engineering Yuanfang Cai Room 104, University - - PowerPoint PPT Presentation
CS 451 Software Engineering Yuanfang Cai Room 104, University Crossings 215.895.0298 yfcai@cs.drexel.edu 1 Drexel University Design Engineering A systematical way to translate SRS into design Start with use cases from SRS
Drexel University
1
Drexel University
A systematical way to “translate” SRS into
Create CRC cards from use cases
Refine CRC cards into UML class diagrams
Different types of classes
2
Drexel University
Information Hiding [Parnas 1972]
Drexel University
Step 1: Identify and assign candidate classes Step 2: Determine a set of specific scenarios Step 3: Walk through the scenario, naming
4
Drexel University
Example: any ATM model will involve Card,
Names are important.
noun identification; responsibility driven approach.
5
Drexel University
Two stages:
identify candidate classes by picking all nouns and noun phrases out of
requirements specification document;
discard inappropriate candidates.
A candidate is an inappropriate class when it is
redundant (ex: book, book in many volumes; member of the
library,library member)
vague (item it may be either book or journal etc) an event or an operation (a loan – an event: lending a book) meta-language element: used to describe and explain requirements
and the system at a very high level (system, rule, information, or reporting requirements)
outside the scope of the system (time) an attribute (name) Nouns are outlined
6
Drexel University
7
Drexel University
CRC Card = Class Responsibility Collaborator
Purpose: interactively brainstorm an initial
Invented in 1989 by Kent Beck and Ward
Drexel University
Class – the name of an OO class (a good descriptive noun) Responsibility – the things the OO class does (behavior responsibility) Collaborator – the relationship the class has with other classes
Class Name Main Responsibility Responsibilities Collaborators . . . . . . 4 X 6 (or 3 X 5) Index card Some also suggest writing down the classes properties (what the class must know about itself – knowledge responsibility) on the back of the card
Drexel University
Slide 10
Main Responsibilit y
A patient makes appointments, review or configure insurance information, and provides medical history
Drexel University
Slide 11
Drexel University
Develop a comprehensive and specific set of
A scenario is a sequence of actions that illustrates
Example:
Requirement: The alarm clock shall allow a user to
Scenario: The user sets the time for 1:15PM.
Drexel University
Walk through the handling of a scenario case
Add new cards as classes are needed. Note: It’s always good to do very
Drexel University
Entity Class
Data Structures
Process Class
Classes that work
Boundary Class
Interface with external systems
14
Drexel University
From the Use Cases to Design
Drexel University
1.1 Preconditions Traffic light has been initialized. 1.2 Main Flow This use case begins when a car enters the intersection. The car checks it’s status (S-1). The use case ends when the car clears the intersection (S-4). 1.3 Subflows S-1 Check Status Check status (S-2, S-3). If the light is green, and the queue is empty, the car clears the intersection (S-4). Otherwise, it joins a queue (S-5). S-2 Check Light Get information on whether the light is red, yellow, or green. S-3 Check Queue Get information on whether the queue is empty or not S-4 Go The car clears the intersection and the use case ends. S-5 Join a Queue Car is added to queue.
Drexel University
Graphical UI vs. Console UI 4-way intersection may become T interaction Lights are usually Green, Red and Yellow Light Changing rules may change
17
Drexel University
The Clear Intersection use case:
“This use case begins when a car enters the intersection. The
car checks it’s status (S-1). The use case ends when the car clears the intersection (S-4).”
“Check status (S-2, S-3). If the light is green, and the queue is
empty, the car clears the intersection (S-4). Otherwise, it joins a queue (S-5).”
Candidate Classes
Drexel University
Scenarios
The car can only drive through the intersection if the
Otherwise, the car needs to join a queue.
Drexel University
Responsibility
Drive Join
Collaborator
Traffic light Queue Intersection Car
Car approaches the intersection and the
light is green and there are no cars in the way.
Car approaches the intersection and the
light is red.
Car is in the queue and the light turns
green.
Drexel University
Class Name Main Responsibility Responsibilities Collaborators . . . . . . 4 X 6 (or 3 X 5) Index card
Turn these cards into your class diagram Responsibilities --- Methods Collaborators --- Associations (need to have instances of
collaboration classes)
Data members on the card back --- Attributes.
Drexel University
Car Traffic light Queue Intersection What else?
22
Car Light Queue
Green? Clear? green Clear go
Drexel University
23
1 1 1
1
Drexel University
24
< < component > > View < < component > > Model < < component > > Controller
Drexel University
25
< < component > > Model < < component > > Controller < < component > > View
Drexel University
26
< < component > > Model < < component > > Controller < < component > > View
View changed() Model changed() Model changed()
Drexel University
27
< < component > > Model < < component > > Controller < < component > > View
Tux
Drexel University
Process/Model Class: 255 LOC
Car.java: 31 LOC CarQueue.java: 51 LOC CarQueueCollection.java: 52 LOC Direction.java: 13 LOC LightCollection.java: 31 LOC LightColor.java: 7 LOC TrafficController.java 70 LOC
UI class:
Traffic.java: 251 LOC Including menu, car queue initialization, etc.
28
Drexel University
Start with use cases from SRS
Find analysis classes from use cases
Create CRC cards from use cases
Refine CRC cards into UML class diagrams
Different types of classes
Architecture Design
Interface Design
Component Design
Detailed/Data Design
29
Drexel University
30
1 1 1
1
Drexel University
Entity Class
Data Structures: CarQueueCollection, LightCollection
Process Class
Classes that work: Traffic Controller
Boundary Class
Interface with external systems: Traffic
31