s o ftw a r e de v e l o p me n t cy c l e

23
Software Development Cycle: 1. Define the problem 2. Plan the solution: Easiest way is to talk to users. Users are familiar with current system and provide the best feedback What are the current problems What features are working Software Development Cycle: 1. Define the problem 2. Plan the solution: Easiest way is to talk to users. Users are familiar with current system and provide the best feedback What are the current problems What features are working What improvements would you like to see Research and examine the existing system: What are its drawbacks and shortcomings Develop model of new software Examine similar systems and look at non computer based solutions. Requirements by the contractor are turned into objectives which will be used by the team To guide the project Evaluate the final product at the end of development cycle Don't worry about things like User interface Data validation The goal is to capture the essential processes of the program To identify inputs and outputs Just building basic program 3. Build the solution 4. Check solution 5. Modify Solution 6. Repeat Why does a new system get designed: New requirements (eg. gov legislation etc) that require a new system Maybe there is no computer based solution in existence Maybe the current system is old and not coping with new technology A business needs to stay competitive The existing system does not satisfy user needs. IPO Charts A number of processes can use the same input to generate different outputs Some outputs become inputs for other processes.

Upload: others

Post on 24-Feb-2022

0 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: S o ftw a r e De v e l o p me n t Cy c l e

Software Development Cycle: 1. Define the problem 2. Plan the solution:

Easiest way is to talk to users. Users are familiar with current system and provide the best feedback

● What are the current problems ● What features are working

Software Development Cycle: 1. Define the problem 2. Plan the solution:

Easiest way is to talk to users. Users are familiar with current system and provide the best feedback

● What are the current problems ● What features are working ● What improvements would you like to see

Research and examine the existing system: ● What are its drawbacks and shortcomings ● Develop model of new software

Examine similar systems and look at non computer based solutions. Requirements by the contractor are turned into objectives which will be used by the team

● To guide the project ● Evaluate the final product at the end of development cycle

Don't worry about things like ● User interface ● Data validation ● The goal is to capture the essential processes of the program ● To identify inputs and outputs ● Just building basic program

3. Build the solution 4. Check solution 5. Modify Solution 6. Repeat

Why does a new system get designed:

● New requirements (eg. gov legislation etc) that require a new system ● Maybe there is no computer based solution in existence ● Maybe the current system is old and not coping with new technology ● A business needs to stay competitive ● The existing system does not satisfy user needs.

IPO Charts

● A number of processes can use the same input to generate different outputs ● Some outputs become inputs for other processes.

Page 2: S o ftw a r e De v e l o p me n t Cy c l e

Create an IPO chart: Program asks user if they want to calculate volume of sphere, cube, rectangular prism or cylinder. Asks if user wants another go.

Input Process Output

Shape Check if shape in list Retrieve shape equation

You chose ‘shape’ Print Equation

Values Put users input values in equation Calculate volume using values

Print Volume

Character Check if user wants to redo using corresponding character

repeat/end

Program asks 20 multiple choice questions and gives four options depending on input provides appropriate apply

Input Process Output

2. Character Check if character = answer

True: Correct False: Incorrect

1. 20 multiple choice questions

Select question Question for user

Terminology:

● System: ○ All the programs in a suite e.g. Microsoft Office (Word, Excel, etc.).

● Program: ○ A set of code modules that perform a task e.g Microsoft Word.

● Code module: ○ A collection of subprograms that together achieve a subtask e.g Edit menu in

Word.

Page 3: S o ftw a r e De v e l o p me n t Cy c l e

● Subprogram: ○ A set of statements that perform a single logical task e.g Cut, Copy or Paste.

Top Down Design: ● Is the most common method for developing software. ● A large complicated problem is broken down into a series of smaller more manageable

problems. ● The same process is used with each of the small problems. ● Eventually large set of very small simple problems that are easy to solve ● Software development must be a precise, detailed process ● Most problems encountered by developers are too large for the entire solution to be

comprehended with sufficient precision and detail ● Top Down Design was developed to overcome this problem ● Breaking something down is also known as:

○ ‘Refinement’ or ‘stepwise refinement’ ○ ‘Decomposition’

● We ignore the big picture (temporarily) ● Consider each small problem and solve it in isolation ● This process is known as ‘abstraction’. ● Once all of the small problems are solved we combine them to create the solution to the

large problem. ● In general, if an algorithm does not fit onto a single page, then top-down design should

be used. ● Advantages of Top Down Design:

○ Modules of code can be reused ○ Programs are easier to write and correct ○ Testing is greatly simplified

■ Each module is small and self contained ■ It can be thoroughly tested in isolation before inclusion in the total solution ■ Testing the total solution is greatly simplified

○ Teams can work on individual modules- the work done by one team will not affect/be affected by the work done by other teams.

● System Modelling Tools ○ These help us to:

■ Understand the problems with the existing system ■ Plan a new system to overcome the problems

○ Usually used before any coding takes place ○ A systematic approach is required when developing software solutions

1. IPO Chart (previous) a. I Wage, Raise percentage b. P NewWage=Wage*(1+ Raise percentage/100) c. O print(NewWage)

2. Context diagram 3. Data Flow Diagram

Page 4: S o ftw a r e De v e l o p me n t Cy c l e

4. Structure Chart 5. Systems Flowchart

● Context Diagrams ○ Give an overview of the system ○ The system is shown as a single process along with inputs and outputs ○ External entities are connected to the system by data flow arrows ○ External entities are sources or destinations of data ○ AKA Level 0 Data Flow Diagrams

● Data Flow Diagrams:

○ Represent the processing performed by a system ○ Data flow diagrams identify:

■ The source of data ■ The processes performed on the data ■ The flow of data between processes ■ Its destination of data (including databases) ■ The data itself

○ Symbols: ■ Circle represents a process. ■ Labelled, curved arrow represents data flow between other

symbols ■ A rectangle represents an external entity ■ An open-ended rectangle represents a data store.

○ How to draw a DFD: ■ The IPO chart gives the processes

Page 5: S o ftw a r e De v e l o p me n t Cy c l e

■ Draw these as labelled circles ■ The context diagram gives most data sources and destinations

(external entities). ■ Draw these as labelled rectangles ■ Re-read the question looking for data stores ■ Draw these as labelled, open-ended rectangles

Page 6: S o ftw a r e De v e l o p me n t Cy c l e

■ Draw data flow lines showing how data travels ● From sources to processes ● Between processes ● To and from data stores ● From processes to destinations

■ Label the data flow lines with the names of the data that travels along with it

IPO Chart:

Input Process Output

Values (Height and width)

Calculate surface area of wall using values.

Surface area

Accumulation Add surface area to existing total

Total surface area

Character Check if user wants to add another value using corresponding character.

Repeat/

Values (Roll area)

Calculate number of rolls using values

Number of rolls

Context Diagram:

Page 7: S o ftw a r e De v e l o p me n t Cy c l e

Data Flow Diagram:

● Structure Charts: ○ Represent a system by showing

■ The separate subprograms that comprise the system and ■ Their relationship to each other

○ Shows the top-down design of a system ○ Shows the relationship of code modules to each other ○ Rectangles = code modules ○ Lines show the connections between them ○ Subprograms on lower levels called by the connected module above ○ All subprograms called by a single parent module and are read from left to right

to show the order of execution ○ Read from top to bottom and left to right ○ Symbols:

■ Unfilled circle arrow represent data movement between modules or subroutines.

■ Filled circle arrows represent a flag or control variable. ■ Right angle junction represents a binary or multiway decision between

Page 8: S o ftw a r e De v e l o p me n t Cy c l e

modules or subroutines ■ Curved arrow indicates repetition of subroutines. Has an annotation next

to it saying ‘until…’ ○ How to draw a structure chart:

■ Draw and label a rectangle for the program mainline ■ Examine the IPO chart - each process will be a seperate subprogram ■ Draw and label rectangles for each process. Make sure they are ordered

from left to right. ■ If there are lower sub-processes then draw these below or above.

Remember to always put in order. ■ Draw lines to connect the processes to the mainline. ■ Draw lines to connect sub-process to parent processes. ■ Any processes that repeat should be labelled with a curved arrow. ■ If there is a choice between processes then the connecting lines should

be gathered at a right angle junction. ■ Draw and label open circle arrows for data that passes to/from processes

and sub-processes ■ Draw and label closed circle arrows for boolean variables that pass

to/from processes and sub-processes. ● What improvements would you like to see

Research and examine the existing system: ● What are its drawbacks and shortcomings ● Develop model of new software

Examine similar systems and look at non computer based solutions. Requirements by the contractor are turned into objectives which will be used by the team

● To guide the project ● Evaluate the final product at the end of development cycle

Don't worry about things like ● User interface ● Data validation ● The goal is to capture the essential processes of the program ● To identify inputs and outputs ● Just building basic program

3. Build the solution 4. Check solution 5. Modify Solution 6. Repeat

Why does a new system get designed:

● New requirements (eg. gov legislation etc) that require a new system ● Maybe there is no computer based solution in existence ● Maybe the current system is old and not coping with new technology ● A business needs to stay competitive ● The existing system does not satisfy user needs.

Page 9: S o ftw a r e De v e l o p me n t Cy c l e

IPO Charts ● A number of processes can use the same input to generate different outputs ● Some outputs become inputs for other processes.

Create an IPO chart: Program asks user if they want to calculate volume of sphere, cube, rectangular prism or cylinder. Asks if user wants another go.

Input Process Output

Shape Check if shape in list Retrieve shape equation

You chose ‘shape’ Print Equation

Values Put users input values in equation Calculate volume using values

Print Volume

Character Check if user wants to redo using corresponding character

repeat/end

Program asks 20 multiple choice questions and gives four options depending on input provides appropriate apply

Input Process Output

2. Character Check if character = answer

True: Correct False: Incorrect

1. 20 multiple choice questions

Select question Question for user

Terminology:

● System: ○ All the programs in a suite e.g. Microsoft Office (Word, Excel, etc.).

● Program: ○ A set of code modules that perform a task e.g Microsoft Word.

Page 10: S o ftw a r e De v e l o p me n t Cy c l e

● Code module: ○ A collection of subprograms that together achieve a subtask e.g Edit menu in

Word. ● Subprogram:

○ A set of statements that perform a single logical task e.g Cut, Copy or Paste. Top Down Design:

● Is the most common method for developing software. ● A large complicated problem is broken down into a series of smaller more manageable

problems. ● The same process is used with each of the small problems. ● Eventually large set of very small simple problems that are easy to solve ● Software development must be a precise, detailed process ● Most problems encountered by developers are too large for the entire solution to be

comprehended with sufficient precision and detail ● Top Down Design was developed to overcome this problem ● Breaking something down is also known as:

○ ‘Refinement’ or ‘stepwise refinement’ ○ ‘Decomposition’

● We ignore the big picture (temporarily) ● Consider each small problem and solve it in isolation ● This process is known as ‘abstraction’. ● Once all of the small problems are solved we combine them to create the solution to the

large problem. ● In general, if an algorithm does not fit onto a single page, then top-down design should

be used. ● Advantages of Top Down Design:

○ Modules of code can be reused ○ Programs are easier to write and correct ○ Testing is greatly simplified

■ Each module is small and self contained ■ It can be thoroughly tested in isolation before inclusion in the total solution ■ Testing the total solution is greatly simplified

○ Teams can work on individual modules- the work done by one team will not affect/be affected by the work done by other teams.

● System Modelling Tools ○ These help us to:

■ Understand the problems with the existing system ■ Plan a new system to overcome the problems

○ Usually used before any coding takes place ○ A systematic approach is required when developing software solutions

1. IPO Chart (previous) a. I Wage, Raise percentage b. P NewWage=Wage*(1+ Raise percentage/100)

Page 11: S o ftw a r e De v e l o p me n t Cy c l e

c. O print(NewWage) 2. Context diagram 3. Data Flow Diagram 4. Structure Chart 5. Systems Flowchart

● Context Diagrams ○ Give an overview of the system ○ The system is shown as a single process along with inputs and outputs ○ External entities are connected to the system by data flow arrows ○ External entities are sources or destinations of data ○ AKA Level 0 Data Flow Diagrams

● Data Flow Diagrams:

○ Represent the processing performed by a system ○ Data flow diagrams identify:

■ The source of data ■ The processes performed on the data ■ The flow of data between processes ■ Its destination of data (including databases) ■ The data itself

○ Symbols: ■ Circle represents a process. ■ Labelled, curved arrow represents data flow between other

symbols ■ A rectangle represents an external entity

Page 12: S o ftw a r e De v e l o p me n t Cy c l e

■ An open-ended rectangle represents a data store. ○ How to draw a DFD:

■ The IPO chart gives the processes ■ Draw these as labelled circles ■ The context diagram gives most data sources and destinations

(external entities). ■ Draw these as labelled rectangles ■ Re-read the question looking for data stores ■ Draw these as labelled, open-ended rectangles

Page 13: S o ftw a r e De v e l o p me n t Cy c l e

■ Draw data flow lines showing how data travels ● From sources to processes ● Between processes ● To and from data stores ● From processes to destinations

■ Label the data flow lines with the names of the data that travels along with it

IPO Chart:

Input Process Output

Values (Height and width)

Calculate surface area of wall using values.

Surface area

Accumulation Add surface area to existing total

Total surface area

Character Check if user wants to add another value using corresponding character.

Repeat/

Values (Roll area)

Calculate number of rolls using values

Number of rolls

Context Diagram:

Page 14: S o ftw a r e De v e l o p me n t Cy c l e

Data Flow Diagram:

● Structure Charts: ○ Represent a system by showing

■ The separate subprograms that comprise the system and ■ Their relationship to each other

○ Shows the top-down design of a system ○ Shows the relationship of code modules to each other ○ Rectangles = code modules ○ Lines show the connections between them ○ Subprograms on lower levels called by the connected module above ○ All subprograms called by a single parent module and are read from left to right

to show the order of execution ○ Read from top to bottom and left to right ○ Symbols:

■ Unfilled circle arrow represent data movement between modules or subroutines.

■ Filled circle arrows represent a flag or control variable. ■ Right angle junction represents a binary or multiway decision between

Page 15: S o ftw a r e De v e l o p me n t Cy c l e

modules or subroutines ■ Curved arrow indicates repetition of subroutines. Has an annotation next

to it saying ‘until…’

○ How to draw a structure chart:

■ Draw and label a rectangle for the program mainline ■ Examine the IPO chart - each process will be a seperate subprogram ■ Draw and label rectangles for each process. Make sure they are ordered

from left to right. ■ If there are lower sub-processes then draw these below or above.

Remember to always put in order. ■ Draw lines to connect the processes to the mainline. ■ Draw lines to connect sub-process to parent processes. ■ Any processes that repeat should be labelled with a curved arrow. ■ If there is a choice between processes then the connecting lines should

be gathered at a right angle junction. ■ Draw and label open circle arrows for data that passes to/from processes

and sub-processes ■ Draw and label closed circle arrows for boolean variables that pass

to/from processes and sub-processes. ● System Flow Chart:

○ Represent a system by showing: ■ The flow of data ■ The separate modules and files comprising the system ■ The media used.

○ Represents: ■ Major processes ■ Physical devices that capture, store and display data ■ Some have become outdated as a result of changes in technology

○ System flowcharts are distinctly different from program flowcharts (represent the

Page 16: S o ftw a r e De v e l o p me n t Cy c l e

logic in an algorithm). ○ Do not use a start or end symbol ○ Do not represent complex logic

Representing Data on a computer

● Computers process digital data ● Digital data is a set of discrete electrical voltages ● For convenience humans think of digital data strings as binary digits.

How does a computer decide what a set of binary digits means: ● For example 10010011 may be

○ Part of an instruction ○ Character ○ Integr

The computer uses data types ● Is software that interprets a string of binary digits ● Software assigns all data items a data type ● This will determine

○ How the data is represented in binary Simple Data Types

● Typically: ○ Boolean ○ Integer ○ Floating point numbers ○ String of characters

Usually built in to the programming language Variables

● Aka identifiers ● Store data used by the programmer ● Must have a data type ● The data type will determine:

○ How data will be stored and represented in the computer ○ How it can be processed ○ How it can be displayed

Boolean ● Used to represent True or False (0 or 1)

Character Coding Systems ● Traditionally used 1 byte for each character ● So 2 to the eight. 256 possible characters ● Sufficient for the english klanguage and some punctuation ● EBCIDIC- character coding system developed by IBM that used a byte.

Page 17: S o ftw a r e De v e l o p me n t Cy c l e

ASCII Code ● Originally 7 bits then 8 ● 128 diferent combinations in the standard ASCII set. ● Characters are gtrouped to facilitate the sorting and searching ● The diference between uppercase and lowercase is 32 ● Students are required to know some ASCII code:

○ 0-9 ○ A-Z ○ a-z

● The problem with ASCII ○ Computers became a worldwide commodity as the internet developed ○ Insufficient capacity to represent some languages- Chinese uses thousands of

characters ○ Hence the the multi byte representation Unicode was developed

Unicode: ● 32 bits ● Designed to include all possible characters and marks used by all the languages of the

world ● ASCII is the subset of Unicode

integer

● Is a whole number ● Uses two bytes ● Therefore 2 to the 16 = 65536 possible combinations of bits ● If the integer type is used we must be certain that no fractional values can be assigned

to these variables ● Type mismatch error = attempting to assign a fractional value to an integer variable ● Often used for loops as counters. ● Most programming languages contain two integer data types ● Short (16 bits)- stores integers in the range -32768 to 32767 ● Long 32 bits- stores integers in the range -2147483648 to 2147483647 ● Integer calculations are:

○ Fast ○ Perfectly accurate

● It is preferred to use integer calculations whenever possible ● Range limitations restrict use.

Floating Point:

● Used to store ○ Fractions ○ Very large or very small numbers

● Does not represent all numbers exactly ● The more decimal places used the better the accuracy, however this involves using

more storage and use of a faster processor ● A compromise between accuracy and storage/speed must be achieved ● Large and Small numbers

○ Any decimal real number can be written in scientific notation ○ Floating point uses a similar approach

Page 18: S o ftw a r e De v e l o p me n t Cy c l e

○ The decimal part is called the mantissa ○ The power of ten is called the exponent.

● The IEEE standard uses ○ 32 bits (single precision) ○ 64 bits (double precision)r

● The exponent represents and integer power of two and is usually stored as one or more bytes.

● Feature of Floating Point ○ Unable to exactly represent many fractions (even fairly simple ones) ○ As calculations progress especially where there is a large number of operations

the degree of accuracy of the result is reduced due to the truncation or overflow. ○ To improve the accuracy use a larger number of bytes (double precision floating

point) ● Floating point arithmetic is difficult and processor intensive. ● Most programming languages have a single and double precision data type that

corresponds to the IEEE standard ● Use floating point only when the requirement of the problem give no other choice.

String:

● Modern programming languages have two options for strings ○ Fixed length- can hold up to a set number of characters ○ Dynamic- can grow in size as required

● Some programming languages require programmers to define strings themselves as sequences of characters.

Shortcomings of simple data types ● Using simple data types for sets of related data can become unwieldy as each data item

would require a unique identifier ● EG, temp1, temp2, temp3 etc ● A more convenient approach is to use a single identifier for the collection of data and

then use a method to access particular data items The decimal number system:

● Ten symbols are used. The ten numbers ● Integers are made by combining symbols and using place values based on powers of

ten. Computer technology is based on transistors (switches) which can be on or off To store data storage devices need to represent two different states Data is represented by groups of two discrete voltages which humans represent as 1,0 The group of 1,0 are binary numbers. Binary system: 16 bits - largest value = 2^16 32 bits - largest value = 2^32 64 bits - largest value = 2^64 In reality, the set of possible integers is split between positives and negatives 8 bits = 127 to -128 16 bits = 32767 to -32768

● If software generates an integer that is too large for the byte size, an overflow error occurs.

Page 19: S o ftw a r e De v e l o p me n t Cy c l e

● 128, 64, 32, 16, 8 ,4, 2, 1 are the numbers you use ● 1+4+16+64=85 ● 1+2+4+16+32+64+128=247 ● 00100110 ● 11111000

Hexadecimal system: ● Hexadecimal numbers are an alternative way of representing binary commands ● Easier for humans to understand compared to binary ● Base 16 ● Integers are combinations of these symbols ● Uses place value based on powers of 16 ● Can convert binary to hexadecimal./ Break it up into nibbles. Find the binary equivalent

and change it into a hex value. ● 47=00101111

○ =2,15 ○ =2F base 16

Data Structures: ● Simple data types require the declaration of every variable ● This is fine if working with small data sets ● However, imagine a scientist who wants to process a set of rainfall data for every day of

the year or for every day for the last 10 years ● Using simple data types for the above example would be laborious and inefficient ● Structured Data Types:

○ Represent a set of related data elements as a single variable that has a certain “internal structure” that enables storage of multiple values

○ Examples: ■ Daily rainfall for a year ■ Student information ■ Seating plan at a theatre

○ Arrays- 1 or 2 dimensions: ■ Set of related data items that are the same type, cannot be mixed ■ Higher order arrays are possible ■ Each data placeholder is called an element ■ The location of an element is given by it index sometimes called subscript ■ These are integers ■ Arrays must be declared (usually at the beginning of the program) ■ This enables the computer to set aside sufficient memory to hold the

array’s data ■ While there is some nuance to array processing in different programming

languages in many ways there is a lot of similarity ■ The real efficiency of arrays is realised when these data structures are

combined with loops ■ Python does not use arrays. Instead, it uses lists, tuples and dictionaries.

○ Records ■ A set of related data items of different data types ■ Each record is composed of smaller parts called fields ■ Every field can hold data ■ The type of each field can be different

Page 20: S o ftw a r e De v e l o p me n t Cy c l e

■ To access the field we use dot notation - combining the name of the record and the field

■ E.g. Student.FirstName= “Fred” ■ All fields in record though possibly having different data types are related. ■ Example:

● Student.FirstName Student.LastName Student.IQ

■ Records have to be declared so that the computer can manage memory ■ Usually at the start of the program ■ A single record is rarely used by itself in a program ■ A rare example is a date

○ Arrays of records ■ More often they record data structure is combined with the array data

structure to create an “array of records”. ■ This data structure is the basis of databases.

○ Files- sequential and relative ■ A collection of data held in secondary storage ■ A file can be used to hold a number of different data items of different

data types ■ Eg a Markbook File

● String for class name ● Array of records for student names and results ● One dimensional array of floating point numbers for average

scores ■ Some DBMS allow users to link a number of separate files together ■ Relational databases ■ A program called a report generator is used to create output from the

linked files ■ Sequential file:

● Has a simple structure ● Think of the file as a long string of characters ● There are special characters inserted to indicate the end of a field,

end of a record and the end of the file ● To access a particular record all data that comes before it must be

processed ■ Random Access File:

● Allows for direct access of records ● All records are the same length

○ Finally each data type and structure has its strengths and limitations ○ Important to select the most appropriate type/structure in order to solve the

problem ○ It's not always obvious what to pick ○ Think about advantages and disadvantages. ○

● Data Dictionaries: ○ A comprehensive description of each data item in a system ○ Useful reference tool for programmers in a team developing code

Page 21: S o ftw a r e De v e l o p me n t Cy c l e

○ Useful for code maintenance ○ Commonly a table with the following columns:

■ Variable name ■ The size of the variable in bytes ■ The number of characters as displayed on screen ■ The data type ■ Format including the number of decimal places (if applicable) and ■ A description of the purpose of each field ■ An example.

● An arrangement of data items ● “User Defined” data types- humans design the structures of the data type to suit the

required processing ● Aims to simplify access and processing of data.

Algorithms: ● There are many situations where a particular process is repeatedly used in a variety of

programs. ● Some processes are so common that they are called standard algorithms (called a

design pattern in object oriented programming.) ● Programmers keep a bank of these standard algorithms for reference. ● Checking algorithms:

○ Checking an algorithm is about checking the correctness of the logic ○ Checking is a process that should take place throughout an algorithm’s

development ○ Desk checking:

■ The primary technique ■ The method involves working through the algorithm using pencil and

paper ■ Test data is input during the desk check and the values are manually

tracked as the user works with the data passing through the algorithm ■ The expected outputs of the test data should have been separately

determined in advanced given that we know what the purpose of the algorithm

■ Choosing test data for the desk check is critical ■ Criteria for choosing test data

1. Test data should test all possible paths through the algorithm (need data for each side of a decision statement)

2. Test boundary values - used for the condition in decision statements and the condition in a loop:

○ Must include a test data item equal to the boundary value ○ A common source of logic errors, is the incorrect use of

relational operators, e.g. Using > instead of ≥ ■ Many errors occur when the iteration commences

or terminates ■ Questions:

1. To have the user input a positive value that is not 0 to be added to the sum and once a negative value or 0 is entered then the program will tell you if the total sum is greater than 10 or not.

2. 2 paths

Page 22: S o ftw a r e De v e l o p me n t Cy c l e

3. 0 and 10 ■ Steps of desk-checking:

1. Firstly, we must establish the purpose of an algorithm 2. The algorithm is written 3. Test data is determined 4. Ignoring the algorithm, an independent calculation is carried out as

to the expected output of the algorithm 5. Now using the algorithm, the test data is applied to it and the

output determined 6. Compare the output of the desk check to the expected data

■ There are some parts of an algorithm that we do not have to desk check ■ Data validation used for unexpected inputs does not need to be desk

checked ■ In fact, for this course it is not necessary to check that algorithms respond

correctly to unexpected inputs … we assume that all inputs are valid ■ This task of validating input is primarily undertaken when coding the

solution Arrays in Algorithms:

● Arrays must be declared at the start of the algorithm ● To do this we must:

○ Give the array a meaningful name ○ Indicate the size (number of elements) of the array ○ Indicate the data type of the element

● Pseudocode declaration of arrays: ○ Temp is an array of 6 elements of type integer ○ Pay is an array of 4 elements of type float (real) ○ Caps is an array of 2 elements of type string

● Flowchart declaration of arrays: ○ Put pseudocode in a box

● Array index: ○ Every element in an array has a location ○ This is the index (or subscript) of the individual element ○ The index is used to access the individual elements of the array ○ Assume that the index of the first element of the array starts at 1 ○ Some programming languages have the first element with an index of 0

● Populating an array: ○ After an array is declared it is empty ○ Data must be entered into the elements ○ This can be done directly or more commonly using a loop

● Summing an array: ○ A common requirement ○ Adding up all of the elements of an array

BEGIN SUBPROGRAM TempAdd(Temp, total) Temp is an array of real integers total is a real number total=0.0 FOR i=1 TO Temp.length

total=total+Temp[i]

Page 23: S o ftw a r e De v e l o p me n t Cy c l e

NEXT i RETURN total

END SUBPROGRAM