5. Implementing Software Solutions Flashcards
Define Metalanguage
A language used to describe the syntax of other languages
EBNF
<> for variables (non-terminal elements), [] for optional, {} for 0 or more, | for or
Railroad Diagrams
Rectangles for variables (non-terminal elements), circles for literal (terminal elements — written as they appear), outward semicircle for loop, inward semicircle for or
Define Identifier
The name given to a variable, subroutine or function. They must commence with a letter
How are input statements used in programming?
Input statements are used to obtain data and store it in some variable. The source of the data may be the keyboard, a file or some other peripheral device.
How are output statements used in programming?
Output statements are used to send data to devices. This could be the monitor, printer, a file or almost any other output device.
Define assignment
The process of storing the value of an expression in a variable
How are assignment statements used in programming?
Assignment statements are used to set the value of variables and properties. Assignment is not the same as equivalence.
How is sequence used in programming?
It is the control structure that ensures each process is executed in the correct order. In most programming languages sequence is implemented by writing statements in their correct order; each statement being separated by some character.
How is selection used in programming?
By binary selection
How is repetition used in programming?
There are two types of repetition – pre-test and post-test
Syntax errors
Result when source code statements do not adhere to the rules of the programming language. All syntax errors will be detected as the source code is translated into object code.
Runtime errors
Result when for some reason the computer is unable to continue executing instructions. They can be caused by either software or hardware faults. Exceptions are types of runtime errors. Exception handlers are executed when an exception of a particular type occurs.
Examples of runtime errors
Mathematical calculations that cannot be evaluated e.g. division by zero, attempting to find the square root of negative numbers, tan 90
Inaccuracies due to non exact floating point representations e.g. 0.99999999 multiplied by 2 gives the result 2
Data that is out of the range of the identifier’s data type e.g. 16-bit integers will have a range from -32768 to 32767
Infinite calls to subroutines/recursion
Logic errors
When programs do not correctly work as anticipated. The program may continue to execute, albeit incorrectly. They are the most difficult errors to correct.
Examples of logic errors
A loop repeating fewer times than expected, resulting in some data not being processed.
Often logic errors are the cause of runtime errors
For example, a program calculates averages may cause a division by zero error if no data is input
Define bug
An error or defect in software or hardware that causes a program to malfunction
Stubs
A small routine that takes the place of a yet to be written subroutine or is substituted for an existing subroutine. No real processing takes place within the stub, its purpose is to allow testing of the calling routine or to assist the debugging process.
Flags
A boolean variable used to check if a section of the code has been executed. Normally the flag is initialised to false and then set to true if the section of code has been executed. Often a flag will be used to confirm that a particular condition has been met.
Debugging output statements
They can be strategically placed within the code to indicate execution has passed through the point. They can also be used to display the contents of variables at particular points in the code. These statements are removed once the source code has been tested and the bugs removed. Output statements are often used as part of a stub.
Automated debugging tools
Breakpoints halt execution and allow the contents of variables at that point to be interrogated and even changed. Watch expressions can be used to display the contents of variables during expressions. They can also cause execution to halt when a certain condition becomes true.
Data validation
It is common practice to obtain user input as string data. The string is then analysed according to the validation rules appropriate to the particular variable and context. For example, authentication, the process of identifying a user using known information, displays a form to get the username and password from the user, accesses usernames and passwords from a text file, stored passwords are encrypted using a one way hash algorithm such as SHA (Secure Hash Algorithm) so access to the text file does not reveal passwords, and checks if the user has successfully been authenticated.
Define Call
To invoke a routine in a programming language. Calling a routine consists of specifying the routine name and, optionally, parameters.
Define scope
The extent or range of operation of an identifier, where in a program, a given identifier may be accessed.