Software Development and Arrays

advertisement
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
Tools to assist with
System Design
• Task Object Event chart
• Flow Chart
• Pseudo Code
• Paper Prototype
Task Object Event (TOE) chart
Task
Object
Event
Clear the screen
EntDateLabel,
DateDisplayLabel
Startup
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
USRadioButton
Click
End the application
ExitButton
Click
start
Flow Charts
Enter date
Separate
day & month
No
NZ date?
Switch
day & month
Yes
Select
month name
display
end
Pseudo Code
1.
2.
3.
4.
Clear labels
Get DateStr from user
Extract Day & Month from Datestr
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
Traditional
Waterfall
Model
Testing
Commission
Maintenance
Requirements
Specification
Design
Coding
Testing
Waterfall
Model
with backflow
Commission
Maintenance
Other Software
Development Life Cycles
• 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…
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) = 57
BattingScores(3,1) = 74
BatterTotal = BattingScores (3,0)
+ BattingScores (3,1)
BatterMessage.txt = “The total for this batsman is ” _
& BatterTotal
THE END
of the lecture
Download