design, testing and IDE's Flashcards
how to promote maintainability
Comments
Indentation
Procedures/ Functions
Descriptive variable names
Constants declared at top of code
reasons for testing
To ensure:
-no bugs in code
-acceptable performance and usability
-unauthorized access prevented
-program meet requirements
describe iterative testing:
e/ new mod…
pro branches….
checking new mods don’t…
handles situations….
-each new module tested as it’s written
-checking new modules don’t introduce new errors into existing code
-ensures program handles erroneous data and exceptional situations
when is final testing performed
when development of program is considered finished
describe final testing
-testing all modules work together
-ensures valid results produced
-beta test may find more errors
State how many parameters are passed into the giveChange() subroutine.
giveChange(money – price)
1
Two variables are inside the brackets. Candidates did not recognise this as a calculation.This calculation would be completed before the function call. Only the result is passed into the function as the parameter. So it’s 1.
A car dealership uses a computer system to record details of the cars that it has for sale.
Each car has a make,model, age and number of miles driven.The car dealership only sells cars that have fewer than 10 000 miles and are 5 years old or less.
*ask the user to enter the number of miles and the age of a car
*validate the input to check that only sensible values that are in the given range are entered
*output True if valid data has been entered or False if invalid data has been entered.
miles = input (“enter miles driven”)
age = input (“enter age of car”)
valid = True
if miles > 10000 or miles < 0 then
___valid = False
elseif age > 5 or age < 0 then
___valid = False
endif
print(valid)
Robust Programming features:
-writing code that anticipates range of possible inputs
can be valid or erroneous
-‘bad’ inputs don’t crash program
-prompts to user: descriptive & helpful
-only correct data type entered
-checking and handling missing or blank data
difference betw/ erroneous and invalid data type
invalid: correct data type outside of accepted range
erroneous: incorrect data type, includes no input given
input validation techniques
-data type check
-range check
-presence check
-format check
-length check
Two methods of translating high-level language: Compiler
Compilers:
-whole program needs to be translated before it can be run
-produces executable file
assembly code is translated by an ….
assembles
advantages of Compilers:
disadvantages:
-speed of execution is faster
-code usually optimised
-original source code kept secret
dis:
-program won’t run with syntax errors, more difficult to write code
-code needs to be recompiled when changed
Method of translating: Interpreter:
-program translated line by line as program is running
-needs to be translated every time its run
-needs to be recompiled
dis/advantages of interpreters
-easy to write source code bcs program will always run, stopping when syntax error found
-no need for recompiling when code changed
-easy for beginners
dis:
-translation software needed at run-time
-speed of execution: slower
-source code needed
-code not optimised