Category Archives: 2. Software Development

Topic 8 Real World Programming

today we started the topic 8 notes, so far we have been learning the programming side to the software development, but topic 8 is all about the other stages.

The stages of the software development cycle are as follows:

Analysis:-the main purpose of this stage is to be absolutely clear about what the program is supposed to do. We must turn a rough idea of what we want the program to do into a detailed description of how it will behave, by asking questions on what the I/O are, and what type of computer it will run on etc. Through this we create the software specification, agreed on by both the client and the developer. This is a very important document and it is a basis of a contract between the client and the developer. It sets out exactly what the client is paying the developer to produce. It can be used at the end of development to resolve any disputes.

Design:- a lot of people just jump into implementation when giving a task. But you MUST not do this, you need to design the program your going to create. Designing the program before implementaion will make is easier. Create Structured Diagrams, or Pseudocode to make it easier to see what steps are needed to make the program work. In real-world programming a test plan is created before implementation begins. The test plan is based on the software specification.

Implementation:- This is where you change the program design into a programming language. This is done by a team of programmers, a team approach is possible if the code used modular program design. Modular programming allows you to re-use section of pre-tested code.

Advantages of modular programming are:

  • it allows programmers to work indepentandly on different sections of the software.
  • Any modules developed with me well documented for inclusion into a module library for future use.
  • and Sections of the overall software can be tested independantly as their developed, this making tracking and destroying bugs easier.

Testing:- Testing is a vital part of any development process.

their are two types of testing. Systematic and Comprehensive.

Systematic Testing: this means that the testing is planned and structured, rather than just random tests. A test plan is developed during the design stage.

Comprehensive Testing: this means that everything is tested. Every part of every module, and aswell as the whole program. Comprehensive testing inclused testing under Normal, Extreme and Exceptional circumstances. The criteria for passing the test stage will have been laid down in detail in the software specification

Testing Normal Conditions: Making sure the program does what i should do when used “normally”. E.g. a program where you enter a number between 1 and 10. Entering numbers such as 4,5,6 are testing it normally.

Testing Extreme Conditions: Making sure the program can handle situations that are at the edge of what would be considered normal. E.g. the same example above, numbers such as 1 and 10 would be testing the extreme conditions.

Testing Exceptional conditions: making sure it can handle unexpected situations of inputs that its not designed to cope with. E.g. The same example as above, numbers such as 15, -98, 11 are all testing the exceptional conditions.

Documentation:- When you buy a peice of software, their are usually two peices of documentation inside. The user guide, and the technical guide.

The user guide tells you how to use the product, and might also include a tutorial, taking you through the uses of it step by step.

the Technical guide gives you technical information of the product. E.g. The software requirements how much RAM the software needs to run, the OS that it works on and how fast the processor needs to be. It should also contain instructions on how to install the software.

Evaluation:- Evaluation involves reviewing the software under 8 headings. These headings are:

1. Is the program fit for purpose?
2. Is the user interface good to use?
3. Is the program code readable
4. Is the program robust?
5. Is the program reliable?
6. Is the program portable?
7. Is the program efficient?
8. Is the program maintainable?

The definition of all the words in Itallic are all in the software development glossary that you were given out. If you do not have this glossary you can find it here.

THIS IS VERY IMPORTANT FOR THE COURSEWORK!

Online resources

Just a reminder that you have access to a large number of resources you can access even if you are not at school.

I have added the powerpoint from today’s lesson to the Glow learn area, I am going to stop add files into the Glow Group and I will convert it to a learning space before the prelim.

Coursework – good and bad

The lesson today was the first in over 2 weeks. We have had very bad snow in Scotland and this has resulted in a lot of missed work. The class were reminded about Scholar, Glow and other resources.

The class was sorted into friendship pairs and I issued sample coursework to the pairs. One half of the room had candidate 2 and the other candidate 3. The pairs were to discuss the coursework given out and look at the example to find out if it was a good or poor candidate. Both example students had passed the coursework task when it was given but one had scrapped a pass and the other had achieved 58/60. We swapped sheets and took notes about what is expected during the coursework.

The class has had some problems with glow so we undertook a sample homework assessment to make sure that the class could submit the homework for Tuesday on time. Scott Brown scored full marks in the sample homework.

Homework will be posted in Glow tonight.

Solution to 6.5.3 task 1

Ok so this is going to be a long post (I will need to check the blog options and shrink the post sizes). This is a solution to task 1 in 6.5.3 it is based on the design given in the answers. It is NOT the only solution and you might want to comment on ways the program could be improved (think about evaluation). I have included some screen shots.

NOTE the display of the data is optional.

Option Explicit

Private Sub Command1_Click()
'This program represents a solution to 6.5.3 task 1
'The Desgin was given in the answers section
'It is not the only solution
Dim HD_up As Integer 'HD Upgrade required
Dim RAM_up As Integer 'RAM Upgrade required
Dim Mon_up As Integer 'Monitor Upgrade required
Dim Cost1 As Single 'Price
Dim Num As Integer 'Quanity
Dim Basic_Cost As Single 'Cost for Order before deliver and discounts
Dim Dis As Single ' Discount on whole order
Dim Del As Single ' delivery charge per order
Dim VAT As Single 'VAT on Order
Dim Total As Single ' Order Total
Cost1 = 499 'Set the starting cost of a machine
Del = 50 ' £50 delivery per order
Form1.Print "The basic systems costs 499" 'optional
Call Get_Comp_Spec(HD_up, RAM_up, Mon_up)
Call Calc_Cost_Of_One(Cost1, HD_up, RAM_up, Mon_up)
Call Get_Number(Num)
Call Calc_Basic_Cost(Num, Cost1, Basic_Cost)
Call Calc_discount_delivery_VAT(Num, Basic_Cost, Dis, Del, VAT)
Call Calc_total_cost(Basic_Cost, Dis, Del, VAT, Total)
Call Display_total(Total)
End Sub

Private Sub Get_Comp_Spec(ByRef HD_up As Integer, ByRef RAM_up As Integer, ByRef Mon_up As Integer)
'Check what upgrades the user wishes
HD_up = MsgBox("Do you wish to upgrade to 60GB for £30?", vbYesNo)
RAM_up = MsgBox("Do you wish to upgrade to 1GB for £50?", vbYesNo)
Mon_up = MsgBox("Do you wish to upgrade to 21 inch for £199?", vbYesNo)
End Sub

Private Sub Calc_Cost_Of_One(ByRef Cost1 As Single, ByVal HD_up, ByVal RAM_up, ByVal Mon_up)
'calculate the cost of the upgrades
If HD_up = vbYes Then
Cost1 = Cost1 + 30
Form1.Print "Hard drive upgrade £30" 'optional
End If
If RAM_up = vbYes Then
Cost1 = Cost1 + 50
Form1.Print "RAM upgrade £50" 'optional
End If
If Mon_up = vbYes Then
Cost1 = Cost1 + 199
Form1.Print "Monitor upgrade £199" 'optional
End If
End Sub

Private Sub Get_Number(ByRef Num As Integer)
'Get the number of systems ordered
'As an extension task this number could be validated
Num = InputBox("How many machines do you want?")
Form1.Print Num & " machines ordered" 'optional
End Sub

Private Sub Calc_discount_delivery_VAT(ByVal Num, ByVal Basic_Cost, ByRef Dis As Single, ByRef Del As Single, ByRef VAT As Single)
'Calculate Discount
If Num > 10 And Num <= 20 Then
Dis = Basic_Cost * 0.05 '5% Form1.Print "A discount of 5% is £" & Dis 'optional
ElseIf Num > 20 Then
Dis = Basic_Cost * 0.1 '10%
Form1.Print "A discount of 10% is £" & Dis 'optional
Else
Dis = Basic_Cost * 0 '0%
Form1.Print "A discount of 0% is £" & Dis 'optional
End If
'Calculate VAT
Form1.Print "Delivery on the order is £" & Del 'optional
VAT = (Basic_Cost - Dis + Del) * 0.175
Form1.Print "The VAT on the order is £" & VAT 'optional
End Sub

Private Sub Calc_Basic_Cost(ByVal Num, ByVal Cost1, ByRef Basic_Cost As Single)
'Calculate the cost of the order before discount and VAT
Basic_Cost = Num * Cost1 ' Cost for whole order
Form1.Print "The cost of the order before discount,deliver & VAT is £" & Basic_Cost 'optional
End Sub

Private Sub Calc_total_cost(ByVal Basic_Cost, ByVal Dis, ByVal Del, ByVal VAT, ByRef Total As Single)
'Calculate the Total cost of the whole order
Total = Basic_Cost + Del + VAT - Dis
End Sub

Private Sub Display_total(ByVal Total)
'Display the cost for the whole order
Form1.Print "The total for the order was £" & Format(Total, "0.00")
End Sub

Displaying 20 Names and Marks in An Array

Today we were given the task of adapting Fridays program to display 20 names and scores from a listbox as well as working out the average mark as a percentage, in another one of Mr Strattons trademark programming tasks. As usual we were let loose on the computers, where, after 15 minutes of confusion and entering paragraphs of code, Mr Stratton questioned us as to who had actually jotted down a design before implementing it. He eventually posted a possible solution which is shown below:

Private Sub CmdStart_Click()
‘load an Array with data from a list box
‘list box is hidden on the form
‘List Boxes count from 0 so add a heading to the fist item
Dim IntNumber(20) As Integer
Dim StrName(20) As String
Dim intavg As Integer
Call Load_Array(IntNumber(), StrName())
Call Calc_Average(IntNumber(), intavg)
Call Display_Array(IntNumber(), StrName(), intavg)
End Sub

Private Sub Load_Array(ByRef Number() As Integer, ByRef StrName() As String)
Dim Counter As Integer ‘local Variable
For Counter = 1 To 20
Number(Counter) = LstNumbers.List(Counter)
StrName(Counter) = LstNames.List(Counter)
Next
End Sub

Private Sub Calc_Average(ByRef IntNumber() As Integer, ByRef intavg As Integer)
Dim IntSum As Integer
For Counter = 1 To 20
IntSum = IntSum + IntNumber(Counter)
Next
intavg = IntSum / 20
End Sub

Private Sub Display_Array(ByRef Number() As Integer, ByRef StrName() As String, ByVal intavg)
‘Standard procedure as used in previous programs
Dim Counter As Integer ‘local Variable
For Counter = 1 To 20
Form1.Print StrName(Counter) & ” scored ” & Number(Counter) & “%”
Next
Form1.Print “Average = ” & intavg & “%”
End Sub

And thats it folks, I’ll leave Danielle to fill you in with the rest.

VB Program for Displaying the Average of 20 Marks

Below is the program from today’s lesson. It is not completed, I would like you to Change the program to display the average with two decimal places. Please add your solution with a comment below.

Private Sub CmdStart_Click()
'load an Array with data from a list box
'list box is hidden on the form
'List Boxes count from 0 so add a heading to the fist item
Dim IntNumber(20) As Integer
Dim StrName(20) As String
Dim intavg As Integer
Call Load_Array(IntNumber(), StrName())
Call Calc_Average(IntNumber(), intavg)
Call Display_Array(IntNumber(), StrName(), intavg)
End Sub

Private Sub Load_Array(ByRef Number() As Integer, ByRef StrName() As String)
Dim Counter As Integer 'local Variable
For Counter = 1 To 20
Number(Counter) = LstNumbers.List(Counter)
StrName(Counter) = LstNames.List(Counter)
Next
End Sub


Private Sub Calc_Average(ByRef IntNumber() As Integer, ByRef intavg As Integer)
Dim IntSum As Integer
For Counter = 1 To 20
IntSum = IntSum + IntNumber(Counter)
Next
intavg = IntSum / 20
End Sub

Private Sub Display_Array(ByRef Number() As Integer, ByRef StrName() As String, ByVal intavg)
'Standard procedure as used in previous programs
Dim Counter As Integer 'local Variable
For Counter = 1 To 20
Form1.Print StrName(Counter) & " scored " & Number(Counter) & "%"
Next
Form1.Print "Average = " & intavg & "%"
End Sub

Parameter Passing with Arrays

The program you are about to see is known as a top down design this means that a problem is taken and broken down into smaller parts, worked out and executed.
You will see in this program that sub programs are used, these correspond to each level of the program this means that the program will run and only pick up on mistakes when it gets to that level. Also you could use breakpoints which will stop at the point you allocate the breakpoints too.
This type of program is known as a parameter this means that the pieces of information passes in and out of the program, to make the program work smoothly you must choose either byValue or byRefrence, by val means that the program does not change where as byref means the program will change.

Display the times table of the users choice
Option Explicit
Private sub CmdStart_Click()
‘Set up variables
Dim multiple As integer
‘Get Multiplier from user
Call GetValue(multiple)
‘Display table
Call DisplayTable(multiple)
End sub
Private sub GetValue(ByRef intvalue As Integer)
intvalue = InputBox(“Please enter the value”)
End sub
Private sub DisplayTable(ByVal multiple)
Dim Counter As Integer
Dim Answer As Integer

For counter = 1 to 12
Answer = multiple * counter
lstOutput.AddItem multiple & “X “ & Counter & “=” & Answer
Next
End Sub

Given you have typed in the correct coding the program should work however you need to look out for the byval and byref parts, in your second private sub because it is in the list box this will be what the answer is and multiple of your number, byVal is the correct one to use, however watch out if you put byRef in it’s place, this would keep the value as 0 and multiply by 0 and not the user’s input, this is because byVal stays the same meaning because the computers first number is 0 it will stay as 0, whereas byRef changes it and would therefore display the user’s input choice of multiple.

Program Code for Times Table

Change the program code below so that the program performs the calculation in a separate procedure from the display.

Option Explicit
Private Sub CmdStart_Click()
'Set up variables
Dim multiple As Integer
'Get Multiplier from user
Call GetValue(multiple)
'Display table
Call DisplayTable(multiple)
End Sub


Private Sub GetValue(ByRef intvalue As Integer)
intvalue = InputBox("Please enter the value")
End Sub


Private Sub DisplayTable(ByVal multiple)
Dim Counter As Integer
Dim Answer As Integer
For Counter = 1 To 12
Answer = multiple * Counter
lstOutput.AddItem multiple & " X " & Counter & " = " & Answer
Next
End Sub