unit 2b - programing techniques Flashcards
what is a scope?
the area of a program where an item (variable, constant, subroutine etc.) is recognised by the program
what is a subroutine?
a selection of code that you can group together under a name and then call later in the program
example:
SUBROUTINE showKeys()
OUTPUT “keyboard controls”
OUTPUT “=============”
ENDSUBROUTINE
showKeys()
note that the subroutine above has no parameters hence the empty brackets
what is data validation?
it ensures that the data entered is the right type
what can validation not ensure?
it cannot ensure that the user has not typed in the wrong value or if there is a spelling mistake but rather if the data is reasonable and conforms to a set of rules
what are the 5 types of validation checks?
range check, type check, length check, presence check, format check
what does a range check do?
checks whether a number or date is within a sensible/allowed range
what does a type check do?
checks if the data is the right type eg. string or integer
what does a length check do?
checks if the data entered is of the right lengtheg. between a certain number of characters
what does a presence check do?
checks if data has been entered into a field or not ie. in case the field has been left blank
what does a format do?
checks if the data is the correct format eg. if was a postcode or email address
what is verification?
it is used to double check that the data has been typed in correctly
what is double-entry verification?
example: if a user is making a new password, they may be asked to enter it twice and if the two passwords don’t match, they’ll be asked to enter it again
what is authentication used for?
used to make sure a person is who they claim to be - checks this by identifying a valid username and password
how can programs be made easier to understand and maintain?
- comments to show who wrote the program and when
- comments to explain what the harder parts of code do
- comments to explain the functionality of each subroutine (function or procedure)
- meaningful variable names
- a modular structure
what are trace tables used for?
used to determine the outputs from a program as it runs. enables a programmer to find errors in their programs
how do your create a trace table?
- make a column of each variable used in the order in which they appear
- record the value of each variable as it changes