Practical Programming COMP153-08S Week 6: Program Design/Development, Arrays.

Post on 11-Jan-2016

213 views 1 download

Transcript of Practical Programming COMP153-08S Week 6: Program Design/Development, Arrays.

Practical ProgrammingCOMP153-08S

Week 6: Program Design/Development, Arrays

Four Essential Phases for Software Development

• Requirements

– Specifications from user, analysis from

programmer

• System Design

• Coding

• Testing

Tools to assist with System Design

• Task Object Event chart

• Flow Chart

• Pseudo Code

• Paper Prototype

Task Object Event (TOE) chart

Task Object EventClear the screen EntDateLabel,

DateDisplayLabelStartup

1.Get date from User:

2.Calculate day, month

3.Display in DateDisplayLabel

AddDateButton Click

1.Calculate new day, month

2.Display in DateDisplayLabel

NZRadioButton

USRadioButtonClick

End the application ExitButton Click

Flow Chartsstart

Enter date

Separate day & month

NZ date?

Select month name

Switch day & month

display

end

No

Yes

Pseudo Code

1. Clear labels

2. Get DateStr from user

3. Extract Day & Month from Datestr

4. If not NZ date then

swap Day & Month

5. Determine MonthName

6. Display Day and MonthName

7. End

Paper Prototype

Software Development Life Cycle

• Has birth, various stages, then an end

• A model of the phases in which software is built

• Many different variations

• Programming is only a small part

Big Bang Model

• Developer receives problem statement

• Developer works in isolation for a long

period of time

• Developer delivers results

• Developer hopes client is satisfied

Requirements

Specification

Design

Coding

Testing

Commission

Maintenance

TraditionalWaterfall

Model

Requirements

Specification

Design

Coding

Testing

Commission

Maintenance

WaterfallModel

with backflow

• Rapid Prototyping Model• Build prototypes before real system

• Formal Methods – Transformation• Animate/Prove specification

• Design steps that preserve correctness

• Iterative/Spiral Model• Build final system in several independent sections

• Extreme Programming Model• Small iterations, Frequent testing, Pair

Programming…

Other Software Development Life Cycles

What is an Array?

What is an Array?

What is an Array?

• A group of items that are

stored together, that have

similar characteristics,

and are related in some way

What is an Array in Visual Basic?

• A group of variables that are

stored together, have the same

data type,

and are named in the same way

Creating an Array

• Dim NZBWCD(9) as string

• Dim Players(14) as string

• Dim BatsmanScore(11) as Integer

• Dim Absentees() As String ={“Jim”, “James”, “John”, “Jack”}

• Dim Heights() As Decimal = {48, 54, 82, 59, 78, 68, 54}

Storing Data in an Array

• NZBWCD(5) =“NZO6”

• Players(6) = “Peter”

• BatsmanScore(0) = 100

• Absentees(2) = “Mary”

• Heights(5) = 100

Two other Array Commands

• Array.Sort(Players)

• Array.Reverse(BatsmanScore)

Parallel One Dimensional Arrays

• Two (or more) one dimensional arrays whose elements are directly related by their position

GolpherName(0) relates to GolpherScore(0)GolpherName(1) relates to GolpherScore(1)GolpherName(2) relates to GolpherScore(2)

• Note: be careful when sorting these!• Note: these arrays have different data types.

Two Dimensional Arrays

Dim BattingScores(11,1) As Integer

BattingScores(3,0) = 57BattingScores(3,1) = 74

BatterTotal = BattingScores (3,0) + BattingScores (3,1)

BatterMessage.txt = “The total for this batsman is ” _ & BatterTotal

THE END

of the lecture