13
1 Fall 2007 ACS-1903 Techniques for designing code Storyboards •Text (aka pseudocode) •Diagrams Flowcharts (a procedural technique) Text presents one of these for the If/Else structure Directed lines indicate flow of execution UML activity diagrams (an OO technique) UML is an OO standard for diagramming for OO systems Directed lines indicate flow of execution

Techniques for designing code

  • Upload
    zaynah

  • View
    25

  • Download
    0

Embed Size (px)

DESCRIPTION

Techniques for designing code. Storyboards Text (aka pseudocode) Diagrams Flowcharts (a procedural technique) Text presents one of these for the If/Else structure Directed lines indicate flow of execution UML activity diagrams (an OO technique) - PowerPoint PPT Presentation

Citation preview

Page 1: Techniques for designing code

1Fall 2007 ACS-1903

Techniques for designing code

Storyboards•Text (aka pseudocode)•Diagrams

Flowcharts (a procedural technique)Text presents one of these for the If/Else structureDirected lines indicate flow of execution

UML activity diagrams (an OO technique)UML is an OO standard for diagramming for OO systemsDirected lines indicate flow of execution

*Note: Be familiar with UML

Page 2: Techniques for designing code

2Fall 2007 ACS-1903

Techniques for designing code

Do the following steps in order

alien moves up

alien says "Slithy toves?"

robot's head turns around

robot turns to look at alien

Do together

robot moves toward the alien

robot legs walk

alien moves down

robot turns to face the camera

robot blushes

robot says “Houston, we have a problem!”

A storyboard in text form:

Page 3: Techniques for designing code

3Fall 2007 ACS-1903

Flowchart for Action Sequence

Action 2

Action 1

A simple sequence of actions. Looks the same in UML.

Page 4: Techniques for designing code

4Fall 2007 ACS-1903

Action Sequence

A simple sequence of actions is a Do in order structure in Alice

Page 5: Techniques for designing code

5Fall 2007 ACS-1903

UML for Parallelism

Action nAction 1

If a set of actions are to be done at the same time they can be represented in a UML activity diagram as

Page 6: Techniques for designing code

6Fall 2007 ACS-1903

Parallel Set of Actions

A Do together structure in Alice specifies that certain actions are to be done at the same time… i.e. in parallel

Page 7: Techniques for designing code

7Fall 2007 ACS-1903

Flowchart for If/Else

expression

action(s) when falseaction(s) when true

falsetrue

An if/else results in one of two actions being executed depending on the truth or falsity of some expression

Page 8: Techniques for designing code

8Fall 2007 ACS-1903

UML for If

• As a UML activity diagram

[false expression][true expression]

Actions for false expressionActions for true expression

Page 9: Techniques for designing code

9Fall 2007 ACS-1903

If/Else

expression

Page 10: Techniques for designing code

10Fall 2007 ACS-1903

Flowchart for Loop

index < limit? Loop action(s)

false

true

Loop action(s) executed while an index goes from 0 up to a limit

Set index to 0

Increment index

Page 11: Techniques for designing code

11Fall 2007 ACS-1903

UML for Loop

Loop action(s)[index >= limit]

[index < limit]

Loop action(s) executed while an index goes from 0 up to a limit

Set index to 0

Increment index

Page 12: Techniques for designing code

12Fall 2007 ACS-1903

Loop

Loop action(s) executed while an index goes from 0 up to but not including a limit*Also: see the more complicated version of loop

Page 13: Techniques for designing code

13Fall 2007 ACS-1903

A UML diagram for Robot Discovering Alien

Alien moves upAlien says “Slithy toves?”Robot turns head aroundRobot faces alien

Alien moves downRobot faces cameraRobot blushesRobot says “Houston, we have a problem!”

Robot moves 1m towards alien Robot leg moves Robot other leg moves

Index 1Limit distance between alien and robot

Increment index

[Index < limit]

[Index >= limit]

Where does the If/Else

from the other day fit

into this?