1 software development int2/higher. 2 software what is software? –all programs that allow hardware...

140
1 Software Development Int2/Higher

Upload: kristopher-bryan

Post on 02-Jan-2016

224 views

Category:

Documents


0 download

TRANSCRIPT

1

Software Development

Int2/Higher

2

Software

• What is software?– All programs that allow hardware to do

something useful and interesting

• You probably use several different pieces of software every day/week– Examples?

• What is hardware?– Everything that you can touch

3

Software

• A piece of software is simply a list of instructions that are fed to the computer and executed

• It is therefore important that these instructions are in the correct order and the instructions themselves are correct

4

Questions• Complete the following table:

Item Hardware software

Monitor

Database

Windows XP

Scanner

An e-mail

Internet Explorer

Mouse

Modem

Computer game

Word processor

Digital camera

5

The Development Process

• The software development cycle is a systematic approach to producing software. The software development life cycle can be summed up in the following stages:

Analysis Design Implementation Testing Documentation Evaluation Maintenance

6

Development Process• It can be difficult to remember all

of these stages in order. • This mnemonic might help. Or,

you might develop your own. A Dance In The Dark Every Monday

nalysis

ocumentat ion

mplementation

esting

esign

valuation

aintenance

7

Software Development Process

• Analysis – To look at the problem and determine what the solution might be.

8

Software Development Process

• Use existing systems or write a new program?

• Turn the rough idea into an exact description.

• What are the inputs and outputs?• What type of computer will it be run

on? • All of these questions must be

answered at this stage.

9

Who does it?

• The systems analyst is the person who is responsible for the analysis stage

10

Skills of the Systems Analyst

• Usually a skilled and experienced programmer

• Good people skills

• Good communication skills

11

What do they do?

• Interview clients

• Observation notes – of existing practice

• Questionnaires

• All of these are categorised as requirements elicitation

12

The Importance of Being Analytical

• The systems analyst has to be very detailed and accurate– So the rest of the process runs smoothly– Examples of what could go wrong?

– After requirements elicitation the analyst will create a requirements specification (program/problem specification) – contains a full problem description, inputs and outputs etc

13

Put the following in the correct order

– 1. Create a user manual– 2. Get the team together to discuss what the

game’s purpose is and what kind of things the player will be able to do

– 3. Create the game– 4. Fix the problems found in testing. Produce

downloadable updates for the game– 5. Design the games characters and worlds.

Produce a plan for when certain parts of the game should be finished

– 6. Make sure the game works properly– 7. Allow some people to play the game and

ask them what they think of it

14

Blob Diagram(analysis)

• Used to determine the inputs and outputs to a program, using making a cup of tea as an example:

Making tea

Tea bag

water

milk

sugar

Used tea bag

Boiled water

Cup of tea

15

Blob Diagram

• Create a blob diagram for the following program

• A program that asks the user the length and breadth of a floor in metres. It will also ask the user the price of the carpet they will use (in m2) and then tells the user how much carpet will be required and the total cost

• (When you have done this, try to create the program in Visual Basic)

16

Blog Entry: The Software Development Lifecycle

• Higher– The 7 stages of the

SD Lifecycle– Analysis – What

happens here, who does it, how do they do it and what do they produce

– Techniques – what techniques are used

• Int2– The 7 stages of the

SD Lifecycle– Analysis: What

happens at this stage and what is produced

– Blob diagram

17

Software Development ProcessDesign

• Jumping straight into coding a program is not a good idea.

• The design stage is important as the details of the program are worked out here.

• Things like how the screen will look

18

Software Development ProcessDesign

• How the user will interact with the program

• How the program might be structured.

• There are a variety of design methods. Pseudocode and structure diagrams are two of the most common.

19

Pseudocode

• Like an English version of the program but can have code in it too if the designer knows how they will code it

• If done properly the pseudocode should match the program line for line

1. Take making a cup of tea as an example2. Fill kettle3. Boil kettle4. When kettle boiled pour hot water in cup5. Add tea bag, milk and sugar6. Stir

We can then use this as the design for our program

20

Your turn

• Write the Pseudocode for the following:

• A program that asks the user which times table they wish to be displayed. The program will then display that times table in a list box

21

Structure Diagram

• Fairly simple, take the tea making example

Making tea

Fill kettle Boil kettle StirWhen kettle boiled pour into cup

Add milk, sugar

22

Structured Diagram

• Like an English version of the program but can have code in it too if the designer knows how they will code it

• If done properly the pseudocode should match the program line for line

1. Take making a cup of tea as an example2. Fill kettle3. Boil kettle4. When kettle boiled pour hot water in cup5. Add tea bag, milk and sugar6. Stir

We can then use this as the design for our program

23

Structure Diagram(with data flow)

• Indicates what variables are passed in and out of procedures

Area of rectangle

Get sizes Calculate area Display area

Find out length Find out breadth

Area = length x breadth

Length

breadth

Length

breadth areaarea

24

Structure diagram

• Draw the following structure diagrams (with data flow)– A program that calculates the area of

people’s gardens when given the length and breadth in metres

– A program that works out the average test score for a pupil from 3 different test scores

25

Software Development ProcessImplementation

• This is the process of turning the design into a suitable programming language.

• We will use a High Level Language, called Visual Basic.

• Testing – A great deal of time is spent on testing. A wide range of conditions will be tested. Normal, extreme and exceptional testing.

26

Software Development ProcessTesting

• A great deal of time is spent on testing. A wide range of conditions will be tested. Normal, extreme and exceptional testing.

27

Documentation

• User Guide: Details of how to use the program

• Technical Guide: The minimum specifications required of the computer you wish to install the software on. Will also contain installation instructions

28

Maintenance

• The 7th and last stage of the development process– Continuous

• 3 types of maintenance– Corrective– Perfective– Adaptive

29

Maintenance• Corrective

– Fix bugs that appear when program is in use– Company might make downloadable “patch” available

• Perfective– Adding new features– Might mean a new a version of the software is

created

• Adaptive– When software needs to take account of some

change in the conditions it operates in• E.g. new version of operating system for example was

designed for Windows XP and adapted to run on Windows Vista

30

Order these steps correctly

• A – writing a user guide and technical guide for the software

• B – Deciding the game you want to create, and what features you want it to have

• C – adapting the game to run on a different type of computer

• D – Actually writing the program code• E – Checking that the program does what it is

supposed to do, is easy to use, and can be fixed if there is a problem

• F – working out the details of what the screens will look like, what menus and functions there will be, and other detailed aspects of the program

• G – Getting users to try out the program to make sure it works under most conditions

31

High Level Languages (HLLs)

• Just like human language, there are many different types of programming language

• Each has been designed to solve a specific type of problem

• Each has it’s own strengths and weaknesses

32

ANALYSIS – the user requirements are determined at this stage

DESIGN – Software and Program design are detailed at this stage

IMPLEMENTATION – actual program put into operation

TESTING – errors and bugs corrected

DOCUMENTATION – technical and user guide drawn up.

EVALUATION - refinements

MAINTENANCE-upgrading

SOFTWARE DEVELOPMEN

T

LIFECYCLE

Copy this diagram

33

High Level Languages (HLLs)

• Visual Basic is an example of a High Level Language

• High Level Languages contain ‘normal’ words and are close to English

• This makes them relatively easy for us to understand

• However, as we know computers only understand binary

34

Machine Code

• Computers only understand binary, the only input a processor will accept is a binary code and it will only give this as output, these are known as Machine Codes

• There are a number of problems with Machine Codes– They are different from processor to processor– Hard for humans to understand and use– Difficult to find and fix errors

35

Low Level Languages

• Low level languages are closer to the language that the computer can understand

• It is very difficult to track down and fix bugs using these languages

36

Questions

• Which type of language (high or low) is easier to understand?

• Which type would be easier to correct if it had a mistake in it?

• Name 2 low level languages• Name 2 high level languages• Explain the main differences between high

and low level languages• List 2 advantages of high level languages

37

High/Low Level Languages

• High– Visual Basic– Pascal– Logo– Java

• Low– Machine Code– Assembler

38

How does a computer understand a HLL?

• The short answer is it doesn’t– What could we do if we wanted to

communicate with a Chinese person who doesn’t speak English and we don’t speak Chinese?

• Get a translator

• This is exactly what a computer does• Every HLL has a translator to

translate it to code the computer understands

39

Translators

• There are 2 different types of translator– Compiler and Interpreter

• Each has strengths and weaknesses

40

Interpreters

• Take each line one at a time and convert to machine code– This is the reason that Visual Basic tells

you when you’ve made a mistake at the end of each line

• This means when a program is run the line has to first be translated and then executed, which slows the program down

41

Interpreters

• The program needs to be translated each time it is run so there is no way to speed the process up.

• This means the interpreter and the program must be stored after the program is complete

• Where the program goes the interpreter is needed

42

Compiler

• Translates the program when it has been completed

• It takes the whole program and converts it to machine code at once

• This machine code can be kept and run as many times as you want

• Means the program runs faster• Only the compiled program needs to

be stored

43

Questions

• Name the two main types of translator programs

• Which one translates the whole program into machine code before it is executed?

• Which translates the program line by line?• Why do machine code programs run more

quickly on a computer than high level language programs?

44

Text Editors

• Implementation of a program takes place in a high level language(HLL)

• High level languages are very close to English and therefore we can use tools much like those we would use when typing an essay e.g. cut and paste

• HLLs can be typed in a word processing package and saved as a text file, ready for translation to machine code

45

Scripting Language and Macros

• This unit is mostly concerned with the process of developing stand alone applications in high level languages

• However small programs can be developed within some existing application packages

• These are called macros– Macros are time saving programs written in a scripting

language which can be activated by a series of key strokes for repeated use. They will only work with an application program, they cannot exist alone.

• They can extend the functionality of an application

• They customise applications

46

Questions

• What is a macro?

• What type of language is used to write macros?

• What are the advantages of using macros?

• Describe 2 examples where a macro could be useful.

47

Variables(Implementation)

• We declare variables in our program to hold values that might change throughout the execution of our program

• We will be mainly using 3 variable types in this course. String (for text), Integer (whole numbers) and Single (numbers with fractions)

• If we declare a variable as a certain type the program will expect this type to be used when trying to set a value for a variable

48

Variables(Implementation)

• It is good practice to declare all of the variables at the start of the program

Dim name as String

Dim age as Integer

Dim rate_of_pay as Single

Dim is short for Dimension

name

A space in memory

age

rate_of_pay

49

Which variable type?

• 0.456 • Jones • -56 • 291• Mike • 17.886 • 3.14 • R2D2

50

Which variable type?

• 0.456 • Jones • -56 • 291• Mike • 17.886 • 3.14 • R2D2

SingleStringIntegerIntegerStringSingleSingleString

51

Exercise

• Which of the following excerpts of code will give errors?:

(a) Dim name as String Name = “Derek”

(b) Dim price as Singleprice = “Derek”

(c) Dim price as Integerprice = 30

52

Formatting Output

• It is good practice to format your output accordingly e.g. if you are outputting a monetary value it should look like this: £3.90

• There is a function in VB6 that takes care of this for you, cleverly it is called the Format function and can be used like this:

Format(price, “currency”) this has the effect of formatting the variable price so that when it is output to the screen it will have a £ sign added automatically

53

Formatting Output

• Some other examples

Format(price, “.0”) to one decimal place

Format(price, “.000”) to 3 decimal places

54

Naming Conventions

• Label – start with lbl

• TextBox – start with txt

• Command Button – cmd

• Picture box – pic

• List Box - lst

55

Naming Conventions

• It is a good idea when naming objects, such as labels, text boxes or command buttons, to give them relevant names

• cmdEnternames, picDisplaymark

• Name like these tell you something about the object rather than command1, picture1

56

Variable Names

• Remember that variable names give us an easy way to refer to a storage location in memory– Rather than using the address

• Variables will be used in every program• In large programs there can be hundreds

of variables• Good variable names make a program

more readable

57

• It is therefore very important and good practice to use sensible, meaningful variable names. Sometimes this means using multiple words– Whitespace is not allowed – So “user age” is not allowed– However– “userage” or “user_age” and “userAge” are all

OK

Variable Names

58

Commenting

• It is good practice to comment your code so that– You can understand the program– You can see where you left off if you

don’t get a program finished– Makes it readable– Helps maintenance as often in software

companies more than one person will work on a program so comments help others see what you are trying to do more easily.

59

Commenting

• To comment we simply type an apostrophe (‘) after the line of code and anything after it will be ignored by the computer e.g.

Dim name as String ‘ declares a name variable with the type string

60

Exercise

1. What function will the objects with the following names have? cmdEnd, txtShowmarks, lblTelluser, cmdGetmarks

2. Which of these variable names would be accepted by VB6 ? Student_Marks, Student Names, Variable1, Variable_One, studentChoices, MstakesAple

3. State why this Visual Basic 6 statement is not valid. ‘Dim Age as Integer ’Declare the Age variable as a whole number

3. Which of these variable names would be accepted by VB6 but are not following proper variable naming? Student_Marks, Student Names, Variable1, Variable_One, studentChoices, MstakesAple

61

Making Decisions

• Often the programs we write won’t always go straight from start to finish

• In some programs we will want to make decisions and based on these decisions the program might execute an alternative set of instructions e.g.

If condition then Action 1Action 2ElseAlternative Action 1End If

62

IF statements

• The technique we use to make decisions is an IF statement

IF (userNumber = 1) Then

lblOutput.Caption “ You win the car!”

Else

lblOutput.Caption = “ You Win nothing!”

End If

63

More Complex IF Statements

• Sometimes a decision is not as straightforward as simply IF something = True then do something

• We might need to look at more than one thing being true or a combination of true and false

• We have a set of operators that can be used for this

64

Complex IFs

• For example OAPs to qualify as an OAP, men need to be 65 or over and women need to be 60 or over

• This couldn’t be represented with a normal IF statement

If (sex = “m”) AND (age >= 65) thenPrint “you are an OAP”Else If (sex = “f”) AND (age >= 60) thenPrint “ You are an OAP”ElsePrint “ you are not an OAP, YET!”End IfEnd If

65

Multiple IFs

• It is possible that your program will need to make more than one decision and we can use multiple Ifs to do this e.g

If mark > 70 then grade = “A”

If mark > 60 then grade = “B”

If mark > 50 then grade = “C”

Else

Grade = “Fail”

66

Multiple IFs

• In the example on the previous slide, even if the mark is greater than 70 the other 2 IF statement lines of code will be executed

• This means the program is executing 2 lines of code unnecessarily

• This is inefficient use of resources(processor time/main memory)

67

An efficient alternative

• A more efficient way to code this would be a CASE statement

Select CASE markCase Is >70Grade = “A”Case Is > 60Grade = “B”Case Is > 50Grade = “C”End Select

Select CASE is more efficient because if mark is 75 the grade will be set to “A” and the remaining Case Is lines are ignored, therefore not executing unnecessary code

68

InputBoxes

• So far we have used text boxes to get the user input. We are now going to use a special code word in Visual Basic, InputBox

• When an InputBox is used your program will open a new window with a prompt for the user to enter something

69

InputBoxes

• InputBoxes are used in the following way:

Variable_name = InputBox (“Prompt to the user”, “Title of InputBox”)

Or a real example

UserName = InputBox(“Enter your name”, “Enter Name”)

70

InputBoxes

• This code

UserName = InputBox(“Enter your name”, “Enter Name”)

Would produce the following window when the program is run:

71

MessageBoxes

• InputBoxes are a nice way to collect input to your program as a lot of the work is done for you.

• There is a similar special word we can use for output, MsgBox

• Used like this:

MsgBox (“Thanks for using my program”)

72

MessageBoxes

• This code: MsgBox (“Thanks for using my program”)

• Produces the following:

73

Fixed Loops

• So far, every program you have written starts at the beginning and executes each line till it reaches the end and then stops

• To repeat a program you need to run it again

• It is often useful to be able to repeat a number of lines of a program

74

Fixed Loops

• If we know how many times we want to repeat something we can use a fixed loop

For counter = 1 to 10

Form.Print “Mr McAlpine is the best!”

Next

Will print the statement to the form 10 times

75

Loops using a variable

• If we want a loop that can be repeated a variable number of times we can get the user to input the value for the loop to stop

For counter = 1 to user_inputPrint “this is an example of a variable

loop”Next

76

For…Next other ways to control the loop length

• We can control the loop length using a command called Step

For counter = 1 to 20 Step 2

This would have the effect of adding 2 to the counter each time round the loop rather than the default 1

We can put whatever number we like after the step, depending on how we want the loop to operate

For counter = 10 to 1 Step -1

Would have the effect of going down from 10 to 1

77

Questions

• Write the Visual BASIC coding of a For..Next loop to produce each of the following lists of numbers

A. 3,6,9,12,15,18..33,36B. 0,9,18,27..99C. 10,9,8,7,6,5,4,3,2,1,0D. 0,0.75,1.5,2.25,3,3.75,4.5E. 50,40,30,20,10,0,-10,-20,-30,-40,-50F. 1,4,9,16,25,36,49,64(hint these are all

numbers squared)

78

More Loops

• So far the loops we have used have gone for a set or fixed number of times depending on us setting it up or the user saying how long they want the loop to be

• There is another kind of loop that can be used when we are unsure of when we want a loop to end– Conditional Loop

79

Do..Loop Until

• One type of VB6 loop we can use when we are unsure of the number of times a loop will be repeated is called a Do..Loop Until, it looks like this

DoLines of code to be repeatedLoop Until condition

80

Do..Loop Until

• Here is a real example of this kind of loop:

Do

userInput = InputBox (“What is 2+2?”)

Loop Until userInput = 4

This will keep asking the user the question until they enter 4(the correct answer)

81

While…Wend Loop

• A While loop is also a conditional loop

While ( user_password <> “p4$$w0rd”)

user_password=InputBox(“Enter password”)

Wend

This loop will continue whilst the users entry is NOT p4$$w0rd

82

What kind of Loop?

• Program needs to take in a list of ten names

• Program needs to keep going until the user enters the word “end”

• Program continues until user enters a 4 digit pin

• Program needs to take in four different pieces of information from the user

83

Arrays

• Arrays are useful for times when we need to store lists of related data

• For example 6 test marks for a pupil, we would normally do this

Dim mark1 as integerDim mark2 as integerDim mark3 as integerDim mark4 as integerDim mark5 as integerDim mark6 as integer

84

Arrays

• This would give us 6 independent variables in memory

mark1 mark2 mark3 mark4 mark5 mark6

85

Arrays

• However if we just use this command

Dim mark(5) as integer

We define an array where each variable is referred to by an index e.g. 0,1,2,3

mark0 mark1 mark2 mark3 mark4 mark5

86

Arrays

• An array is very useful as the program can refer to the whole array at once or any single element

• Arrays would normally be used in conjunction with a loop

87

Input Validation

• There is a saying in computing which goes:– Garbage In, Garbage Out (GIGO)

88

89

Input Validation

• It is common for the companies who do things like this to blame it on computer error

• More often these type of errors occur because the program has been fed invalid data

ProgramWrong data in Wrong data out

90

Input Validation

• If we design our program properly we should be able to prevent or at least restrict the amount of wrong data our user is allowed to enter

• An example: we have designed a program that allows teachers to enter their students percentages and it calculates a grade

91

Input Validation

• So the teacher is entering the percentages. They want to enter 59 but are in a hurry and enter 559.

• This would most likely give the student an ‘A’ when they should’ve in fact got a ‘B’– Garbage In, Garbage Out!

• This could be prevented by making it impossible to enter a score of more than 100

92

Input Validation

• A score of over 100 could be described as Invalid in this sense

• Invalid data, is data which makes no sense

• To prevent invalid data being entered we can include our code for data input in a conditional loop that will only stop when valid data is entered

93

Invalid Data

• A program asks a user to enter a date in day/month/year format. Give an example of an entry that would be considered invalid and also a valid entry

• A program asks a user to enter a 5 digit number, give an example of an invalid entry and a valid entry.

94

Input Validation

• Note that Input Validation does not stop mistakes from occurring it simply stops invalid data being entered.– For example it would stop a percentage of 105

being entered but if someone entered 59 instead of 49, validation does not pick up on this

• The process of catching erroneous data is called verification, which is outside the scope of this course

95

Input Validation

• The process of input validation always follows a standard pattern

• Standard patterns save programmers time when programming

• A pattern like this is called a standard algorithm

96

Input Validation

• Here is a simple version of the standard algorithm for input validation

Do

Prompt user for valid input

If input is invalid, warn user

Loop until data is valid

97

Other Standard Algorithms

• Input Validation is an example of a Standard Algorithm

• There are 4 others that you need to know about

• Finding a minimum/maximum, Counting Occurrences and Linear Search

98

Standard Algorithms

• The pattern for Input validation is the same in all scenarios– This saves programmers time when

designing programs

• There are many other instances of these patterns that are re-useable– They are called STANDARD

ALGORITHMS

99

Finding Minimum/Maximum

• These algorithms search lists of numbers and return the value of the minimum/maximum

• E.g in the following list

14, 67, 24, 2, 69, 9, 100, 101

• Minimum?

• Maximum?

100

Finding Min

Will usually be used in conjunction with an array

Set min = first element in arrayFor length of arrayIf current array element < min thenMin = current array elementNext

Print min

101

Finding Max

Will usually be used in conjunction with an array

Set max = first element in arrayFor length of arrayIf current array element > max thenMax = current array elementNext

Print min

102

Counting Occurrences

• Works it’s way through a list of numbers, as it does, it counts the amount of times a certain value appears

• E.g. how many times does 3 appear here?

4, 7, 3, 8, 6, 3, 9, 0, 3, 5

103

Counting Occurrences

Usually involves using an array

To_find = “Dave”

For length of arrayIf current array element = to_findCounter = counter + 1Next

Print Counter

104

Linear Search

• Searches through a list looking for a particular item and returns where in the list the item appears

e.g. search for blue

Red, green, yellow, orange, blue, pink

5 would be returned as blue is the 5th item in the list

105

Linear Search

Usually used along with an array

Name = InputBox “Enter a name to be found”

For counter = 0 to length of arrayIf namearray(counter) = NameDisplay “Name found at “ & counterEnd IfNext

106

Which standard algorithm would we use to solve these

problems?• Search through a list of names to find at

what place the name Steve appears• Make sure the user enters a number

between 1 and 10• Find the month in a list with the lowest

rainfall• Counting the number of times Tiger

Woods has won the US Masters from a list of US Master winners

107

Questions

• Which standard algorithm would be used by the national census to:

• Find out how many people called Mary live in the UK?

• Find out the oldest person living in the UK?

• Discover whether or not there was an individual living in the UK call ‘Stan D. Ard-al-Gorithm’?

108

Pre-Defined Functions

• These carry out standard operations that are commonly used

• They exist for strings (text) and numbers (Integers)

109

Pre-defined String Functions

• UCase (string) capitalises the string• LCase (STRING) puts string to lower case• Len (string) returns the length of the string• Mid$(string, start point, lengthrequired)

returns a section of the string starting at the character specified by the start point and the length specified by the lengthrequired

110

SubStrings

• Essentially taking a chunk out of a string to use for something else: like generating a password or to look for a pattern in a string

• Using Mid$(string to be used, start position, number of letters in the

substring)

111

Concatenation

• Sometimes we will want to output multiple values using a single line of code e.g

MsgBox(“Your total bill is: “ & totalCost)OrMsgBox(“Customer Name: “ & name & VbCrlf &

“Customer Address: “ & address)

Using the & sign is called ConcatenationIt can be used as many times as necessary to get

your output looking like you want it

112

Concatentation

• Remember though that there is a Format function so:

• Something like

MsgBox(Format(price, “Currency”))

Will have the same effect as

MsgBox (“£” & price)

113

Questions

• Match these descriptions to the pre-defined function

Description Pre-defined function

Returns the ASCII code of character Mid$

Selects a group of characters out of a string Asc

Turns any character into upper case LCase

Takes an ASCII code and returns the character it UCaserepresents

Changes any character to lower case Len

Counts the number of characters in a string Chr$

114

Questions Continued

• If sentence = “What is 25 times 8?”), what would be the output from:– A) Mid$(sentence,1,1)– B) Mid$(sentence,1,4)– C) Mid$(sentence,9,2)– D) Mid$(sentence,19,1)

115

Pre-Defined Numeric Functions

• INT(variable containing a fraction) would remove the fractional part, leaving the whole number

• ROUND(variable to be rounded) rounds the number to the NEAREST whole number

• SQR(variable) gives the square root of any number

116

User Defined FunctionsWe can create functions of our own e.g

Function calc_area(length as single, breadth as single) as singleDim area as single

Area = length * breadthCalc_area = AreaEnd Function

We can then use the function as follows

Private sub cmd_click()Dim length as singleDim breadth as singleDim area as single

Area = calc_area(length, breadth)

Form1.Print(Area)End Sub

As the function returns a value

117

Testing

• Any product created will go through rigorous testing

• A wide range of conditions will be used e.g. not only expected inputs in the case of a program– These will be planned at the

design stage• Testing will be systematic and

comprehensive– Systematic means the testing

is planned and not just random tests

– Comprehensive means every aspect is tested

Testing can only prove the presence of bugs, not their absence. Testing finds bugs, de-bugging removes those bugs

118

Normal Testing

• Make sure the program does what it should when being used normally

• A program expects a number to be entered between 0 AND 40– Normal testing would test that the

program did what it should for numbers 1-39

119

Extreme/Boundary testing

• Making sure the program can handle values at the extreme or boundary of what is considered normal.

• Using our 0 to 40 program– Extreme tests would be -1, 0, 40, 41

120

Exceptional testing

• Making sure the program can handle situations or inputs that are unexpected or that the program is not designed for

• Using our 0-40 program– Things like 3000000, y , n , -45690,

hello

121

What kind of testing

• A) program looking for a person’s age and the test data used is: hello, 1000000, steve, oioi70780

• B) program looking for a 4 digit pin code and the data used is: 0000, 0001, 9999

• C) program looking for the price of a slab: 0.50, 1.23, 2.45, 5.60

122

Testing and Robustness

• Testing all conditions provides useful evidence about he robustness of the software– Robustness is the ability of the program

to cope with erroneous/unexpected data

123

Testing

• Testing is carried out by Independent Test teams– Other programmers from within the

organisation– Or perhaps contractors– Or potential clients– Or combination of all of the above

• Testing is carried out at various stages

124

Acceptance Testing

• Acceptance testing is sometimes called Beta testing

• Carried out on the premises where the software will be used, by the people who will use it– Given unrestricted access– Allowed to enter unpredictable input to

test the behaviour of the program

125

Exhaustive Testing

• Testing functionality with all possible valid and invalid data– Is this possible?

• So how much is enough?– How important is the project?

126

Documentation

• After testing has been completed we move onto stage 5 of the development process – Documentation

• Any product you buy, software or hardware will come with a User Guide to tell you how to use the product– This may also contain a tutorial taking you

through the use of the product step by step• Becoming more prevalent to use an

electronic format– More eco-friendly but can also be updated

with the software

127

Documentation

• As well as the user guide for the software, there will also be a Technical Guide of some sort

• Usually this is of no interest to most users, but will contain information about the specification of computer required– E.g. RAM, how fast a processor and which

Operating System the computer needs• Will also contain instructions on

installation of the software• Might also contain information on trouble

shooting

128

Evaluation

• Stage 6 and the final stage before the product is distributed

• Involves reviewing the software to see if it is of the quality required

• We will look at three headings– Fitness for Purpose– User Interface– Readability

129

Evaluation

• User Interface– Is program easy to use?– Is it clear what each menu, command

and button is for?– Could it be improved in any way?

130

Evaluation

• Fitness for Purpose– Does software do as it should under all

reasonable conditions?– Check against the program

specification to make sure (analysis stage)

– Look at test results and making sure the program is free of bugs

131

Evaluation

• Readability– No direct concern of the user– Important for other programs to

understand how the program works– Is it possible for another programmer to

read and understand the code• Needs to be if there will be updates

performed at a later date

132

Evaluation(Higher)

The following questions will be asked:• Is the program robust?• Is the program reliable?• Is the program reliable?• Is the program portable?• Is the program efficient?• Is the program maintainable?

These are expanded in the notes

133

Evaluation

• What 3 criteria are be used for evaluating software?

• What is the relationship between pseudocode and a structure diagram?

• Name 2 items of documentation usually provided with a software package, and describe what you would expect each one to contain.

• What 3 types of testing should be applied to any software?

• Describe 2 examples of maintenance that would be required on a game program.

134

Scope

• Variables can have 2 types of scope– GLOBAL and LOCAL

• Global variables are created outside any subs, functions or procedures and can be used/seen by all subs/functions/procedures

• Local variables are created inside subs and can only be seen/used within that sub

135

Modularity

• Scope gives programmers freedom to create modules without worrying that they are creating variables in their module that conflict with the variables created by the other programmers– E.g. we are creating a school management

program. I am creating the module for pupils and I use the variable firstName. You are creating the module for the teachers and use a variable called firstName. As long as these variables are LOCAL to my sub, e.g. created within my sub there will be no conflict

136

Parameter Passing

• A parameter is just a variable being passed into a subroutine

• Very important programming concept– Ensures variables don’t interfere with

each other– Keeps programs reliable

137

Parameter Passing

• In real programming situations, several programmers are involved in the creation of the program

• The each create sub procedures

Private sub valid_age(byval age as integer)

138

Parameter Passing

Private sub valid_age(byval age as integer)

To execute this sub procedure we would put the line

Call valid_age(person_age)

Note that the parameter passed does not match the variable, this is ok and will still work. As long as person_age is an integer

This allows programmers to write procedures and not worry about what other programmers are calling variables

139

ByVal

• Used if you only need to use the value of the variable

• You won’t be able to change the value of the variable

• You send a copy of it that is discarded after use– Like giving someone a photocopy, they

can write on it etc and throw it away after use, you keep the original

140

ByRef

• Used if you need to change the value of the variable

• They are passed in, updated and passed out for future use– Like giving someone your master copy,

if they change it and give you it back, the changes are permanent