marr collegehigher software developmentslide 1 the software development process – 4 hours
TRANSCRIPT
Marr College Higher Software Development Slide 1
The Software Development Process – 4 hours
Marr College Higher Software Development Slide 2
Soft
ware
Develo
pm
en
t P
rocess
The Software Development Process
The SDP consists of seven main stages that are followed to develop software.
They are:
1. Analysis
2. Design
3. Implementation
4. Testing
5. Documentation
6. Evaluation
7. Maintenance
Marr College Higher Software Development Slide 3
Soft
ware
Develo
pm
en
t P
rocess
The iterative nature of the SDP
The SDP is iterative as any of the stages may be revisited throughout the project.
Example:
If an error is found in the maintenance stage (after release) then the implementation stage will be revisited to fix the code.
Marr College Higher Software Development Slide 4
Soft
ware
Develo
pm
en
t P
rocess
The Software Specification
The Software Specification is a document that defines the scope and boundaries of the project and becomes legally binding between the client and the developers.
Marr College Higher Software Development Slide 5
Soft
ware
Develo
pm
en
t P
rocess
Personnel involved the SDP
Client - commissions the software project as a result of an identified ‘need’.
Systems Analyst – Investigates the client’s current system and designs the new or upgraded system.
Project Manager – Project leader who manages the project and the development team. Ensures deadlines being met and resources are in place.
Programmer – Implements the designs (pseudocode etc.) into program code.
Independent Test Group – tests the software to identify any errors by testing subroutines, modules and the completed program.
Marr College Higher Software Development Slide 6
Soft
ware
Develo
pm
en
t P
rocess
Analysis
The Systems Analyst meets with the client, interviews and observes users of the current system and identifies what the program has to do, in a process known as Requirements Elicitation.
The result is the production of the Software Specification.
Marr College Higher Software Development Slide 7
Soft
ware
Develo
pm
en
t P
rocess
Design
The design process is methodical and involves designing and representing algorithms as pseudocode and/or structure diagrams.
Marr College Higher Software Development Slide 8
Soft
ware
Develo
pm
en
t P
rocess
Design
Algorithm
An algorithm is a sequence of actions that, when performed in the correct order, will solve a problem or task in a finite number of steps.
Example:
Here is a simple algorithm to convert a Fahrenheit temperature to Celsius:
1 Subtract 32 from Fahrenheit temperature2 Multiply by 5/9ths to get Celsius temperature
So,
98.6°F - 32 = 66.666.6 * 5/9ths = 37°C
What happens if you swap steps 1 and 2 - do you get the same answer?
Marr College Higher Software Development Slide 9
Soft
ware
Develo
pm
en
t P
rocess
Design
Pseudocode
Pseudocode is a design notation that combines English language and Maths with programming language constructs.
Marr College Higher Software Development Slide 10
Soft
ware
Develo
pm
en
t P
rocess
Design
Pseudocode
Note:
Pseudocode is not specific to any programming language. It is a design notation that can be implemented by programmers in any programming language
Here is the Fahrenheit conversion algorithm represented as pseudocode to be implemented as program code:
1.1 Get temp(°F)
1.2 Set temp(°F) = temp(°F)-32
1.3 Set temp(°C) = temp(°F)*0.556
1.4 Display temp(°C)
1.1 Get temp(°F)
1.2 Set temp(°F) = temp(°F)-32
1.3 Set temp(°C) = temp(°F)*0.556
1.4 Display temp(°C)
Marr College Higher Software Development Slide 11
Soft
ware
Develo
pm
en
t P
rocess
Design
Structure Diagram
A Structure Diagram is another design notation that represents algorithms in a chart or graphical form
Here is the Fahrenheit conversion algorithm represented as a structure diagram to be implemented as program code:
Covert °F to °C
1.1 Get temp(°F)
1.3 Set temp(°C) = temp(°F)*0.556
1.4 Display temp(°C)
1.2 Set temp(°F) = temp(°F)-32
Marr College Higher Software Development Slide 12
Soft
ware
Develo
pm
en
t P
rocess
Design
Flow chart
A flow chart is another design notation that shows the sequence of operations required to complete a task.
This chart shows the sequence of reading customer accounts and calculating the amount due for each customer.
After an account has been processed, the program loops back to process the next one.
Marr College Higher Software Development Slide 13
Soft
ware
Develo
pm
en
t P
rocess
Design
Top-down design is where a task or problem is broken down into stages that can be solved as individual parts.
This structure diagram illustrates a top-down approach to identifying the stages of the problem solution.
Top-down design
Is the process of breaking a problem down in to sub-problems.
Marr College Higher Software Development Slide 14
Soft
ware
Develo
pm
en
t P
rocess
Design
Stepwise Refinement
Stepwise-refinement is the process of refining stages down into steps. Each step can then be coded in a programming language.
Marr College Higher Software Development Slide 15
Soft
ware
Develo
pm
en
t P
rocess
Implementation
This is where the programmer(s), overseen by the project manager, convert the pseudocode (algorithms) into programming code e.g. Visual Basic, C++, Java etc.
‘Program Code
tempF = txtTempF.Text
tempF = tempF-32
tempC = tempF*0.556
lblTempC = temp(°C)
‘Program Code
tempF = txtTempF.Text
tempF = tempF-32
tempC = tempF*0.556
lblTempC = temp(°C)
Pseudocode
1.1 Get temp(°F)
1.2 Set temp(°F) = temp(°F)-32
1.3 Set temp(°C) = temp(°F)*0.556
1.4 Display temp(°C)
Pseudocode
1.1 Get temp(°F)
1.2 Set temp(°F) = temp(°F)-32
1.3 Set temp(°C) = temp(°F)*0.556
1.4 Display temp(°C)
A formatted printout of the program code is known as a structured listing. It includes indentation, white space and internal commentary.
Marr College Higher Software Development Slide 16
Soft
ware
Develo
pm
en
t P
rocess
Testing
Testing should be both systematic and comprehensive i.e. methodical with test reports of predicted and actual results kept, and tested under all operational situations with a full range of test data.
The three types of testing are normal, extreme and exceptional.
Example
Program should only accept whole values in the range 0 to 100:
Normal data: 2, 34, 66 etc.
Extreme data: 0,100
Exceptional: -1, 156, abc, 2.9 etc.
Example
Program should only accept whole values in the range 0 to 100:
Normal data: 2, 34, 66 etc.
Extreme data: 0,100
Exceptional: -1, 156, abc, 2.9 etc.
Acceptance (beta) testing is when independent test groups and/or the client try out the software and report back any bugs to the development team prior to final release.
Marr College Higher Software Development Slide 17
Soft
ware
Develo
pm
en
t P
rocess
Documentation
To produce documentation to be distributed with the software. The two main documents are the user guide and the technical guide.
1 User Guide
A set of instructions on how to install and use the software perhaps including tutorials and FAQS. Can be in both a booklet or electronic format.
2 Technical Guide
Describes hardware requirements e.g. CPU, RAM space on hard disk etc.
Marr College Higher Software Development Slide 18
Soft
ware
Develo
pm
en
t P
rocess
Evaluation
An evaluation report is prepared and supplied to the client with the release of the software.
Evaluation
Reliable
No design faults
Correct output
Portable
Cross platform
Efficient
Low processor and memory overheads
Maintainable
Readable i.e. internal commentary, indentation etc.
Modular i.e. uses procedures and functions.
Robust
Copes with errors
Does not crash
Fit for purpose
Does the program meet the spec?
Marr College Higher Software Development Slide 19
Soft
ware
Develo
pm
en
t P
rocess
Maintenance
Begins once the software has been released and put into use. Involves the client who uses the software and the programmers to make any necessary changes.
There are 3 types of maintenance.
Corrective: Fixing any errors that were not detected during the testing phase.
Adaptive: To alter the software to work with a new operating system or new hardware.
Perfective: Add new functionality at the request of the client.
Corrective: Fixing any errors that were not detected during the testing phase.
Adaptive: To alter the software to work with a new operating system or new hardware.
Perfective: Add new functionality at the request of the client.
Corrective maintenance is part of the contract whereas adaptive and perfective are usually at additional expense to the client.
Marr College Higher Software Development Slide 20
Languages and Environments – 6 hours
Marr College Higher Software Development Slide 21
Lan
gu
ag
es a
nd
En
vir
on
men
tsProcedural Languages
Programs follow a sequence from start to finish and can be split into sub-programs called procedures.
Languages such as Pascal, Comal and Basic are procedural and nowadays are mainly used for learning programming.
Sample Pascal code
Marr College Higher Software Development Slide 22
Declarative Languages
Declarative (logic) programming has no fixed start or end point; are collections of facts and rules; and use pattern matching to answer queries.
Lan
gu
ag
es a
nd
En
vir
on
men
ts
Declarative languages such as Prolog and LISP are used predominantly in the field of Artificial Intelligence.
Here are some facts:
Parent (Liz, Tom). means that Liz is a parent of TomFemale (Liz). means that Liz is femaleMale(Tom).Parent(Bert, Tom).
Here is a rule:
Mother(X, Y) :- means that X is a mother of Y IF Parent(X, Y), Female(X) X is a parent of Y AND X is female!
Query could be Mother(X, Tom) which would give the answer X=Liz
Marr College Higher Software Development Slide 23
Event-driven Languages
An object-oriented programming paradigm where objects on the interface have their own code attached e.g. a command button.
Visual Basic and Java are examples of event-driven languages.
The code is executed in response to events e.g. form load, button click etc.
Lan
gu
ag
es a
nd
En
vir
on
men
ts
Marr College Higher Software Development Slide 24
Lan
gu
ag
es a
nd
En
vir
on
men
ts
Programs written in high-level languages need to be translated into low-level (machine code) for processing and executing by the CPU. This is done by a translator program.
Translators
There are two types of translator program:
• interpreters
• compilers
Marr College Higher Software Development Slide 25
Lan
gu
ag
es a
nd
En
vir
on
men
ts
Interpreter programs translate HLL code into machine code one line at a time.
Advantages:
easy to find errors
good for learners
Disadvantages:
programs slow as have to be continually interpreted
interpreter program always in memory
Interpreters
Marr College Higher Software Development Slide 26
Lan
gu
ag
es a
nd
En
vir
on
men
ts
A Compiler program translates the whole program (source code) into a machine code version (object code) that can be run without the compiler being present.
Advantages:
programs execute fast as CPU ready
translator program only needed at the time of compiling
different compilers can be written for different platforms.
Compilers
Disadvantages:
slow to compile as whole program translated
also may not run if syntax errors.
Marr College Higher Software Development Slide 27
Scripting Languages
Programs written as scripts are used to automate or extend the functionality of software applications.
Lan
gu
ag
es a
nd
En
vir
on
men
ts
A Macro is a script written in Visual Basic for Applications (VBA).
The user records a series of actions in an application such as MS-Excel.
Code is generated and saved as a program script.
The macro can then be assigned to a keystroke.
Used to simplify and repeat complex or frequently used commands.
Marr College Higher Software Development Slide 28
Module Libraries
A Module Library is a pre-written and pre-tested collection of subroutines and functions which the programmer can use to aid the development of the final program.
Lan
gu
ag
es a
nd
En
vir
on
men
ts
Advantages include:
No code has to be written for problems already solved
The code will have been checked for any errors
The modules will be well documented
Marr College Higher Software Development Slide 29
HLL Programming Constructs – 14 hours
Marr College Higher Software Development Slide 30
String Operations
The two string operations are concatenation and substrings.
HLL P
rog
ram
min
g C
on
str
ucts
Concatenation is the joining together of two strings.
This example will output “Good morning!” to a text box.
Substrings are parts of strings that are extracted and used in some way.
‘Example
first = “Good “
second = “morning!”
whole = first & second
lblMsg.Caption = whole
‘Example
first = mid$(“Phil”,1,1)
second = mid$(“Mitchell”,1,1)
initials = first & second
lblMsg.Caption = initials
This example will output “PM” to a label.
Marr College Higher Software Development Slide 31
Formatting of Input / Output
Data can be input via text boxes, input boxes etc.
Data can be output to the screen by setting properties such as font, colour etc.
Concatenation can be used to output strings and numerical data.
HLL P
rog
ram
min
g C
on
str
ucts
‘Example
lblMsg.Caption = “The total is “ & total & “!!”
‘Example
txtAve.Text = Format(average,”.00”)
‘Example
txtAve.Text = Format(average,”.00”)
Use of pre-defined functions may also format output.
Marr College Higher Software Development Slide 32
Multi-way Selection
The CASE statement improves the IF..THEN..ELSE construct where more than two conditions are possible.
HLL P
rog
ram
min
g C
on
str
ucts ‘Implement using CASE
Select Case mark
Case Is >= 70
grade = “A"
Case Is >= 60
grade = “B"
Case Is >= 50
grade = “C"
Case Else
grade = “Fail"
End Select
‘Algorithm using nested IFs
If mark >= 70 Then
grade = “A"
Else
If mark >= 60 Then
grade = “B“
Else
If mark >= 50 Then
grade = “C"
Else
grade = “Fail"
End If
End If
End IfCASE makes the code more readable so aids maintenance.
Marr College Higher Software Development Slide 33
Variables
A variable is the name used to store a single item of data within a program.
HLL P
rog
ram
min
g C
on
str
ucts
Examples
Integer variables store whole numbers e.g. Dim age As Integer
Real variables store decimal numbers e.g. Dim price As Single
String variables store text e.g. Dim pname as String
Boolean variables store either TRUE or FALSE e.g. Dim Swaps As Boolean
Marr College Higher Software Development Slide 34
1D ArraysH
LL P
rog
ram
min
g C
on
str
ucts
An array is a name given to a list of items of data in a program. The list is stored in contiguous memory locations.
Here is an array nums(10) of integers between 1 and 9:
(1) (2) (3) (4) (5) (6) (7) (8) (9) (10)
3 6 2 5 6 3 9 4 5 7
Here is some VB code to setup and array:
‘Example: 1D array
Dim nums(10) As Integer
Here is some VB code to setup and array:
‘Example: 1D array
Dim nums(10) As Integer
Here is some VB code that would input data to an array:
‘Example: Input to array
For c = 1 To 10
nums(c) = inputbox(“Enter number etc.
List1.additem nums(c)
Next c
Here is some VB code that would input data to an array:
‘Example: Input to array
For c = 1 To 10
nums(c) = inputbox(“Enter number etc.
List1.additem nums(c)
Next c
Marr College Higher Software Development Slide 35
Modularity
Well written code makes use of modular programming. This simply means that programs are organised into modules or sub-programs.
HLL P
rog
ram
min
g C
on
str
ucts
Advantages
Each sub-program can be developed and tested as a standalone program
Bugs can be located within a specific sub-program
Maintenance can be carried out on each
Programs can be sub-divided and developed by many programmers
The two main types of modules are subroutines (procedures) and functions.
Marr College Higher Software Development Slide 36
ProceduresH
LL P
rog
ram
min
g C
on
str
ucts
A procedure is a subroutine that performs a specific task in a program.
A procedure can be invoked by:
a) an event e.g. Private Sub cmdCalculate_Click()
b) being called when needed e.g. Call Validate
Here’s how to create a procedure in VB6:
Private Sub InputNames()
Statements
End Sub
Marr College Higher Software Development Slide 37
Functions
A function is a subroutine that always returns a value e.g. a function could be used to return the result of a calculation.
HLL P
rog
ram
min
g C
on
str
ucts
Note: The value returned from the function must always be assigned to a variable or a control!
Note: The value returned from the function must always be assigned to a variable or a control!
If CalcTax()was a function then you could return a value to a label
e.g. lblAmount.Caption = CalcTax()
Here’s how to create a function in VB6:
Private Function CalcTax () As Single
Statements
End Function
or you could return a value to an expression
e.g. Amount = Estimate * .2 + CalcTax() * .14
Marr College Higher Software Development Slide 38
User-defined Functions
A user-defined function is a subroutine that is coded by the user and ‘called’ by another section of program code. It does not depend on an event.
HLL P
rog
ram
min
g C
on
str
ucts
Marr College Higher Software Development Slide 39
Global Variables
Global variables are declared at the start of a program and can be used anywhere in the program.
HLL P
rog
ram
min
g C
on
str
ucts
Pros and cons
Can be used anywhere in the program
Declared once at the start
If value changes then changes for the rest of the program
Can be changed by mistake
Marr College Higher Software Development Slide 40
Local VariablesH
LL P
rog
ram
min
g C
on
str
ucts
Local variables are declared within a procedure or function and can only be used by that subroutine.
Pros
Different variables can have the same name
Save memory as created and destroyed during subroutine runtime
Make subroutines ‘standalone’ so easy to reuse in other programs
Reduce risk of accidental change of global value
Marr College Higher Software Development Slide 41
Parameter PassingH
LL P
rog
ram
min
g C
on
str
ucts
The two methods of parameter passing are:
i. By reference (in and out)
A parameter is simply the value of a variable that can be passed between subroutines.
age = 25
variable parameter
SubroutineIN
SubroutineIN OUT
ii. By value (in)
Marr College Higher Software Development Slide 42
By reference H
LL P
rog
ram
min
g C
on
str
ucts
Parameter passed is the actual variable itself. Any changes to the parameter persist beyond the call i.e. change the original value.
Subroutine A
25age
age = 25
Subroutine B
Private Sub check (ByRef age)
25age
age = 42
42age
42age
Note: An array should always be passed by reference due to memory overheads.
Marr College Higher Software Development Slide 43
By valueH
LL P
rog
ram
min
g C
on
str
ucts
A copy of the current value of parameter is passed in and any changes do not affect the original value.
25age
Subroutine A Subroutine B
25a
age = 25 Private Sub check (ByVal a)
42a
a = 42
Note: In sub B the variable a is an alias i.e. a copy of the actual parameter.
alias
Marr College Higher Software Development Slide 44
Advantages of parameter passingH
LL P
rog
ram
min
g C
on
str
ucts
There are a number of advantages:
Greater control of data flow
Reduced risk of accidental change
More efficient use of memory
Sub-programs are more ‘self-contained’
Improved reliability and robustness
Here’s how to pass parameters in VB6:
Call AddVat (cost, total)
Private Sub AddVat (ByVal c, ByRef total)
statements
End Sub
Marr College Higher Software Development Slide 45
Standard Algorithms – 12 hours
Marr College Higher Software Development Slide 46
VB6 Code
Pseudocode
1 Input Validation
Validates program input and rejects invalid data.
Sta
nd
ard
Alg
ori
thm
s
1.1 Get and store value
1.2 Loop WHILE data is out with range
1.3 Display error message
1.4 Prompt user to re-enter value
1.5 End loop
num = InputBox (“Enter number between 1 and 10”)
Do While num < 1 Or num > 10
MsgBox “Must be num between 1 and 10”
Num = InputBox (“Enter number between 1 and 10”)
Loop
Marr College Higher Software Development Slide 47
2 Linear Search
Searches a list for a target value.
Sta
nd
ard
Alg
ori
thm
s
Pseudocode
VB6 Code
2.1 Get and store target value
2.2 Loop for each item in the list
2.3 If current item = target value THEN
2.4 Display item and its location in list
2.5 End if
2.6 End loop
target = InputBox (“Enter target value”)
For p = 1 To 10
If array(p) = target Then
picResult.Print target & “found at position “ & p
End If
Next p
Marr College Higher Software Development Slide 48
3 Counting Occurrences
Counts the number of times (frequency)
Sta
nd
ard
Alg
ori
thm
s
Pseudocode
3.1 Set counter = 0
3.2 Get and store target value
3.3 Loop for each item in the list
3.4 If current item = target value THEN
3.5 Increment counter
3.6 End if
3.7 End loop
VB6 Code
times = 0
target = InputBox (“Enter target value”)
For p = 1 To 10
If array(p) = target Then
times = times + 1
End If
Next p
Remember to output e.g. to a label or control array etc.
Remember to output e.g. to a label or control array etc.
Marr College Higher Software Development Slide 49
Pseudocode
4 Finding Maximum
Find largest value in a list.
Sta
nd
ard
Alg
ori
thm
s
4.1 Set max = first item
4.2 Loop for each remaining item in the list
4.3 If current item > max then
4.4 Set max = current item
4.5 Set position = counter
4.6 End if
4.7 End loop
VB6 Code
max = array(1)
For p = 2 To 10
If array(p) > max Then
max = array(p)
pos = p
End If
Next p
Marr College Higher Software Development Slide 50
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
Finds the smallest value in a list….
Marr College Higher Software Development Slide 51
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
Set min to first item in list…
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 52
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
Is 3 less than 21?
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 53
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
If yes then set min as 3.
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 54
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
Is 56 less than 3?
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 55
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
If no then do nothing.
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 56
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
Is 2 less than 3?
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 57
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
If yes then set 2 equal to min.
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 58
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
Is -9 less than 2?
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 59
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
If yes then set min equal to -9.
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 60
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
Is 5 less than -9?
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 61
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
If no then do nothing.
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 62
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
Is 3 less than -9?
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 63
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
If no then do nothing.
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 64
5 Finding MinimumS
tan
dard
Alg
ori
thm
s
-9 is the smallest value in the list.
21 3 56 2 -9 5 3
(1) (2) (3) (4) (5) (6) (7)
min
Marr College Higher Software Development Slide 65
Pseudocode
5 Finding Minimum
Find smallest value in a list.
Sta
nd
ard
Alg
ori
thm
s
5.1 Set min = first item
5.2 Loop for each remaining item in the list
5.3 If current item < min then
5.4 Set min = current item
5.5 Set position = counter
5.6 End if
5.7 End loop
VB6 Code
min = array(1)
For p = 2 To 10
If array(p) < min Then
min = array(p)
pos = p
End If
Next p
Marr College Higher Software Development Slide 66
TASK – Find Min and Max
Write a program that will:
a) allow the user to input 10 scores between 1 and 6. The scores can be real i.e. 2.3, 5.6 etc.
b) Calculate the total score i.e. each of the scores totalled up!
c) Find the minimum and maximum score and subtract from the overall total to obtain a final score. Hint: final = total – (min + max) Use a function!
d) Display all the scores on screen, along with the minimum, the maximum and the final score.
e) Extension: Adapt the program to display each score on screen in ascending (sorted) order as it is entered by the user.
Have fun!!!
McLean
Sta
nd
ard
Alg
ori
thm
s