CS 451 Software Engineering Yuanfang Cai Room 104, University - - PowerPoint PPT Presentation

cs 451 software engineering
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Drexel University

CS 451 Software Engineering

1

Yuanfang Cai Room 104, University Crossings 215.895.0298 yfcai@cs.drexel.edu

slide-2
SLIDE 2

Drexel University

Design Engineering

 A systematical way to “translate” SRS into

design

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 

Data Design

Architecture Design

Interface Design

Component Design

Detailed/Data Design

2

slide-3
SLIDE 3

Drexel University

SOLID

 Information Hiding [Parnas 1972]

slide-4
SLIDE 4

Drexel University

From Use Cases to Class diagrams

 Step 1: Identify and assign candidate classes  Step 2: Determine a set of specific scenarios  Step 3: Walk through the scenario, naming

classes, attributes and responsibilities

4

slide-5
SLIDE 5

Drexel University

 Consists of classes of domain objects.

 Example: any ATM model will involve Card,

BankAccount classes

 Names are important.

 Class identification is a key process for a

good class model:

 noun identification;  responsibility driven approach.

5

Step 1: Identify and assign candidate classes

slide-6
SLIDE 6

Drexel University

Noun identification

 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

slide-7
SLIDE 7

Drexel University

CRC Cards

7

slide-8
SLIDE 8

Drexel University

Introduction to CRC Cards

 CRC Card = Class Responsibility Collaborator

Card

 Purpose: interactively brainstorm an initial

design of a program or program segment

 Invented in 1989 by Kent Beck and Ward

Cunningham

slide-9
SLIDE 9

Drexel University

CRC Cards

 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

slide-10
SLIDE 10

Drexel University

Slide 10

An Example CRC Card - Front

Main Responsibilit y

A patient makes appointments, review or configure insurance information, and provides medical history

slide-11
SLIDE 11

Drexel University

Slide 11

An Example CRC Card - Back

slide-12
SLIDE 12

Drexel University

Step 2: Determine a set of specific scenarios

 Develop a comprehensive and specific set of

end-to-end scenarios based upon the requirements.

 A scenario is a sequence of actions that illustrates

behavior.

 Example:

 Requirement: The alarm clock shall allow a user to

set the time.

 Scenario: The user sets the time for 1:15PM.

slide-13
SLIDE 13

Drexel University

Step 3: Walk through the scenario, naming cards and responsibilities

 Walk through the handling of a scenario case

pointing to or picking up the cards, naming their responsibilities and how they handle and delegate each request.

 Add new cards as classes are needed.  Note: It’s always good to do very

basic/mainstream use cases first, then explore alternative/complicated use cases.

slide-14
SLIDE 14

Drexel University

Step 4: Different types of analysis classes

 Entity Class

 Data Structures

 Process Class

 Classes that work

 Boundary Class

 Interface with external systems

14

slide-15
SLIDE 15

Drexel University

Clear Intersection Example

 From the Use Cases to Design

slide-16
SLIDE 16

Drexel University

  • 1. Flow of Events for the Clear Intersection Use Case

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.

slide-17
SLIDE 17

Drexel University

Possible Future Changes

 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

slide-18
SLIDE 18

Drexel University

Step 1: Identify and assign candidate classes

 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

Car Traffic light Queue Intersection

slide-19
SLIDE 19

Drexel University

Step 2: Determine a set of specific scenarios-From Use Cases

 Scenarios

 The car can only drive through the intersection if the

traffic light is green and there are no cars in the intersection.

 Otherwise, the car needs to join a queue.

slide-20
SLIDE 20

Drexel University

Step 3: Walk through the scenario, naming cards and responsibilities

Index Card: Car

 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.

slide-21
SLIDE 21

Drexel University

CRC Cards  What next?

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.

slide-22
SLIDE 22

Drexel University

Candidate Classes

 Car  Traffic light  Queue  Intersection  What else?

22

Car Light Queue

Green? Clear? green Clear go

slide-23
SLIDE 23

Drexel University

Class Diagram

23

1 1 1

1

slide-24
SLIDE 24

Drexel University

From Classes to Components

24

< < component > > View < < component > > Model < < component > > Controller

slide-25
SLIDE 25

Drexel University

Component Diagram (UML 2.0)

25

< < component > > Model < < component > > Controller < < component > > View

slide-26
SLIDE 26

Drexel University

Component Diagram (UML 2.0)

26

< < component > > Model < < component > > Controller < < component > > View

View changed() Model changed() Model changed()

slide-27
SLIDE 27

Drexel University

Deployment Diagram

27

< < component > > Model < < component > > Controller < < component > > View

Tux

slide-28
SLIDE 28

Drexel University

Final Implemention

 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

slide-29
SLIDE 29

Drexel University

Design Engineering

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

slide-30
SLIDE 30

Drexel University

The Design of Traffic Simulator

30

1 1 1

1

slide-31
SLIDE 31

Drexel University

Different types of analysis classes

 Entity Class

 Data Structures: CarQueueCollection, LightCollection

 Process Class

 Classes that work: Traffic Controller

 Boundary Class

 Interface with external systems: Traffic

31