Evaluation
Course Content
The British Computer Society define evaluation as:
“An objective review of what has been achieved to establish whether it meets the required criteria. The evaluation might also look at the wider context, the user needs and whether there are any undesirable consequences introduced into the solution.”
Burdett, Arnold. BCS Glossary of Computing (Kindle Locations 999-1001). BCS Learning & Development Limited. Kindle Edition.
Evaluation Criteria
There are several criteria that could be used when evaluating your programs but at National 5 we will look at:
Fitness for purpose
Efficient use of coding constructs
Robustness
Readability
Fitness for Purpose
Does it meet the required specification? Each of the requirements should be tested to ensure that it functions correctly and that the program is fit for purpose.
Efficiency
Efficiency can be defined as:
“achieving maximum productivity with minimum wasted effort or expense”
Just because all functional requirements have been met does not that it has been done in the most efficient manner the picture to the right will demonstrate this:
Just because you have a solution to a problem doesn’t mean it is the best. Efficient programs are ones that perform their function using the minimum amount of resources.
Efficient use of coding constructs - Loops
When writing a program (particularly one that is going to be compiled) then it is preferable to use loops.
Even if we take a simple program that would add 1 onto a variable and repeat it a 1000 times with and without loops such as below.
total = total + 1 (x1000 times)
If we ran this with a loop
for x in range(1000):
total = total + 1
The output in Python if we counted the time for both approaches is shown above
The algorithm above finds the average rainfall over 7 days:
This could be made much more efficient by using a fixed loop.
Efficient use of coding constructs - Conditional Statements
Choosing from a number of possible alternatives when using selection can make code more efficient, however, it is not always obvious which is more efficient.
These two programs decide the grade that a candidate is given, depending on the mark they received in the exam.
Inefficient use of conditional statements
IF mark > 70 THEN
SET grade TO A
END IF
IF mark >=60 AND mark <=69 THEN
SET grade TO B
END IF
IF mark >=50 AND mark <=59 THEN
SET grade TO C
END IF
IF mark >=45 AND mark <50 THEN
SET grade TO D
END IF
This uses four IF constructs, one after another, with the use of complex conditional statements.
This program always carries out four comparisons, regardless of the values stored in mark as each IF statement would have to be evaluated.
Efficient use of conditional statements
IF mark>=70 THEN
SET grade=A
ELSE IF mark>=60 THEN
SET grade=B
ELSE IF mark>=50 THEN
SET grade=C
ELSE
SET grade=D
END IF
This uses one IF statement with multiple ELSE IF's.
Nested Selection Statements
If you use a combination of nested or else if statements then it is possible that some conditions may never required to be evaluated and checked. This may not be possible in all cases as it may be that the correct option is the last one. The example below takes the grades from above and evaluates them in a more efficient manner.
We can use nested selection statements to (potentially but not in every case) limit the amount of comparisons.
Readability
How readable is your code?
Meaningful variable names/identifiers assist you (and other developers) to identify the function of programs.
Indentation and the use of white space are also extremely useful
Remember that Python uses indentation instead of delimiters such as { } or ( ) and end if/next loop etc
Robustness
A piece of software is robust if it can deal with exceptional or incorrect data or unusual situations. Your input validation or file access should be one of your main considerations. You cannot deal with every possible scenario but you should aim to test those that may happen - even if you cannot deal with them as yet.