software development

134
1 Software Development Int2/Higher

Upload: dympna

Post on 27-Jan-2016

29 views

Category:

Documents


1 download

DESCRIPTION

Software Development. Int2/Higher. 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. Software. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Software Development

1

Software Development

Int2/Higher

Page 2: Software Development

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

Page 3: Software Development

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

Page 4: Software Development

4

Questions• What is the meaning of the term hardware?• Give three examples of software.• 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

Page 5: Software Development

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

Page 6: Software Development

6

Development ProcessIt can be difficult to remember all of

these stages in order. This little mnemonic might help.Or, you might develop your own. A Dance In The Dark Every Monday

nalysis

ocumentat ion

mplementation

esting

esign

valuation

aintenance

Page 7: Software Development

7

Software Development Process

• Analysis – To look at the problem and determine what the solution might be. 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.

Page 8: Software Development

8

Who does it?

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

Page 9: Software Development

9

Skills of the Systems Analyst

• Usually a skilled and experienced programmer

• Good people skills

• Good communication skills

Page 10: Software Development

10

What do they do?

• Interview clients

• Observation notes – of existing practice

• Questionnaires

• All of these are categorised as requirements elicitation

Page 11: Software Development

11

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

Page 12: Software Development

12

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

Page 13: Software Development

13

Blob Diagram(analysis)

• Used to determine the inputs and outputs to a program, using tea example:

Making tea

Tea bag

water

milk

sugar

Used tea bag

Boiled water

Cup of tea

Page 14: Software Development

14

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

Page 15: Software Development

15

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

Page 16: Software Development

16

Software Development Process

• Design – jumping straight into coding a program is not a good idea. This stage is important as the details of the program are worked out here. Things like how the screen will look, how the user will interact with the program and how the program might be structured. There are a variety of design methods. Pseudocode and structure diagrams are two of the most common.

Page 17: Software Development

17

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

Take making a cup of tea as an example 1. Fill kettle2. Boil kettle3. When kettle boiled pour hot water in cup4. Add tea bag, milk and sugar5.Stir

We can then use this as the design for our program

Page 18: Software Development

18

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

Page 19: Software Development

19

Structure Diagram

• Fairly simple, take the tea making example

Making tea

Fill kettle Boil kettle StirWhen kettle boiled pour into cup

Add milk, sugar

Page 20: Software Development

20

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

Page 21: Software Development

21

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

Page 22: Software Development

22

Software Development Process

• Implementation – 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.

Page 23: Software Development

23

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

Page 24: Software Development

24

Maintenance

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

• 3 types of maintenance– Corrective– Perfective– Adaptive

Page 25: Software Development

25

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

Page 26: Software Development

26

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

Page 27: Software Development

27

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

Page 28: Software Development

28

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

Page 29: Software Development

29

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

Page 30: Software Development

30

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

Page 31: Software Development

31

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

Page 32: Software Development

32

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

Page 33: Software Development

33

High/Low Level Languages

• High– Visual Basic– Pascal– Logo– Java

• Low– Machine Code– Assembler

Page 34: Software Development

34

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

Page 35: Software Development

35

Translators

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

• Each has strengths and weaknesses

Page 36: Software Development

36

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

Page 37: Software Development

37

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

Page 38: Software Development

38

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

Page 39: Software Development

39

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?

Page 40: Software Development

40

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

Page 41: Software Development

41

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

Page 42: Software Development

42

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.

Page 43: Software Development

43

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

Page 44: Software Development

44

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

Page 45: Software Development

45

Which variable type?

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

Page 46: Software Development

46

Which variable type?

• 0.456 Single• Jones String• -56 Integer• 291 Integer• Mike String• 17.886 Single• 3.14 Single• R2D2 String

Page 47: Software Development

47

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

Page 48: Software Development

48

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

Page 49: Software Development

49

Formatting Output

• Some other examples

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

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

Format(average, “percent”) ??

Format(time, “.00\s”)??

Page 50: Software Development

50

Naming Conventions

• Label – start with lbl

• TextBox – start with txt

• Command Button – cmd

• Picture box – pic

• List Box - lst

Page 51: Software Development

51

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

Page 52: Software Development

52

• It is therefore very important and good practice to use sensible, meaningful variable names. Sometimes this means using multiple words

• Some no no’s– Whitespace is not allowed

• E.g user age

• Use capitals to de-limit multiple words– userAge– roomWidth

• Or use under score– User_age– Room_width

• Choose one method and stick to it!

Variable Names

Page 53: Software Development

53

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.

Page 54: Software Development

54

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

Page 55: Software Development

55

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

Page 56: Software Development

56

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

Page 57: Software Development

57

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

Page 58: Software Development

58

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

Page 59: Software Development

59

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”

Page 60: Software Development

60

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)

Page 61: Software Development

61

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

Page 62: Software Development

62

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

Page 63: Software Development

63

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”)

Page 64: Software Development

64

InputBoxes

• This code

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

Would produce the following window when the program is run:

Page 65: Software Development

65

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”)

Page 66: Software Development

66

MessageBoxes

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

• Produces the following:

Page 67: Software Development

67

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

Page 68: Software Development

68

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

Page 69: Software Development

69

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

Page 70: Software Development

70

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

Page 71: Software Development

71

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)

Page 72: Software Development

72

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

Page 73: Software Development

73

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

Page 74: Software Development

74

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)

Page 75: Software Development

75

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

Page 76: Software Development

76

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

Page 77: Software Development

77

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

Page 78: Software Development

78

Arrays

• This would give us 6 independent variables in memory

mark1 mark2 mark3 mark4 mark5 mark6

Page 79: Software Development

79

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

Page 80: Software Development

80

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

Page 81: Software Development

81

Input Validation

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

Page 82: Software Development

82

Page 83: Software Development

83

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

Page 84: Software Development

84

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

Page 85: Software Development

85

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

Page 86: Software Development

86

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

Page 87: Software Development

87

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.

Page 88: Software Development

88

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

Page 89: Software Development

89

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

Page 90: Software Development

90

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

Page 91: Software Development

91

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

Page 92: Software Development

92

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

Page 93: Software Development

93

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?

Page 94: Software Development

94

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

Page 95: Software Development

95

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

Page 96: Software Development

96

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

Page 97: Software Development

97

Counting Occurrences

Usually involves using an array

To_find = “Dave”

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

Print Counter

Page 98: Software Development

98

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

Page 99: Software Development

99

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

Page 100: Software Development

100

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

Page 101: Software Development

101

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’?

Page 102: Software Development

102

Pre-Defined Functions

• These carry out standard operations that are commonly used

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

Page 103: Software Development

103

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

Page 104: Software Development

104

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)

Page 105: Software Development

105

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

Page 106: Software Development

106

Concatentation

• Remember though that there is a Format function so:

• Something like

MsgBox(Format(price, “Currency”))

Will have the same effect as

MsgBox (“£” & price)

Page 107: Software Development

107

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$

Page 108: Software Development

108

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)

Page 109: Software Development

109

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

Page 110: Software Development

110

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

Page 111: Software Development

111

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

Page 112: Software Development

112

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

Page 113: Software Development

113

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

Page 114: Software Development

114

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

Page 115: Software Development

115

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

Page 116: Software Development

116

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

Page 117: Software Development

117

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

Page 118: Software Development

118

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

Page 119: Software Development

119

Exhaustive Testing

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

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

Page 120: Software Development

120

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

Page 121: Software Development

121

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

Page 122: Software Development

122

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

Page 123: Software Development

123

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?

Page 124: Software Development

124

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

Page 125: Software Development

125

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

Page 126: Software Development

126

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

Page 127: Software Development

127

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.

Page 128: Software Development

128

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

Page 129: Software Development

129

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

Page 130: Software Development

130

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

Page 131: Software Development

131

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)

Page 132: Software Development

132

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

Page 133: Software Development

133

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

Page 134: Software Development

134

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