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

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

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

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

Practical ProgrammingCOMP153-08S

Week 6: Program Design/Development, Arrays

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

Four Essential Phases for Software Development

• Requirements

– Specifications from user, analysis from

programmer

• System Design

• Coding

• Testing

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

Tools to assist with System Design

• Task Object Event chart

• Flow Chart

• Pseudo Code

• Paper Prototype

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

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

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

Flow Chartsstart

Enter date

Separate day & month

NZ date?

Select month name

Switch day & month

display

end

No

Yes

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

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

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

Paper Prototype

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

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

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

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

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

Requirements

Specification

Design

Coding

Testing

Commission

Maintenance

TraditionalWaterfall

Model

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

Requirements

Specification

Design

Coding

Testing

Commission

Maintenance

WaterfallModel

with backflow

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

• 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

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

What is an Array?

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

What is an Array?

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

What is an Array?

• A group of items that are

stored together, that have

similar characteristics,

and are related in some way

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

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

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

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}

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

Storing Data in an Array

• NZBWCD(5) =“NZO6”

• Players(6) = “Peter”

• BatsmanScore(0) = 100

• Absentees(2) = “Mary”

• Heights(5) = 100

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

Two other Array Commands

• Array.Sort(Players)

• Array.Reverse(BatsmanScore)

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

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.

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

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

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

THE END

of the lecture