Design, Testing and Translators Flashcards
What is structured programming?
Structured programming decomposes the program that you want to write into manageable modules. Each of these modules is then decomposed even further into smaller modules and eventually into modules that perform individual tasks
Give some advantages of using structured programming.
1) coding is easier because you’re only writing subroutines that carry out very simple tasks
2) lots of programmers can work on one program as each module can be written independently
3) it’s easier to test structured programs as each module can be tested individually
4) individual subroutines and modules can be fixed and updated without affecting the rest of the program
5) you will be able to reuse the subroutines and modules in programs you write in the future
Give some features of maintainable source code.
1) comments are useful for explaining what the key features of a program do
2) indentation can be used to separate different statements in a program
3) variables, subroutines and parameters should be named so that they refer to what they actually are
4) only use global variables when necessary as they could affect the rest of your code
What is authentication?
Authentication can confirm the identity of a user before they’re allowed to access certain pieces of data or features of the program
Why is authentication used?
Authentication is used to improve security
What can be done to make a password-based authentication system more secure?
1) force users to use strong passwords and get them to change their passwords regularly
2) limit the number of failed authentication techniques before access to an account is lost
3) ask for a random selection of characters from the password on each authentication
Define the term ‘input validation’.
Checking if data meets certain criteria before passing it into the program
Give some input validation checks.
1) range check
2) presence check
3) format check
4) look-up table
5) length check
Define the term ‘syntax error’.
When the compiler or interpreter doesn’t understand something you’ve typed because it doesn’t follow the rules or grammar of the programming language
Define the term ‘logic error’.
When the compiler or interpreter is able to run the program but the program does something unexected
Why are logic errors more difficult to diagnose than syntax errors?
Compilers and interpreters won’t pick them up
What are the three different types of test data?
1) normal (typical) data
2) boundary (extreme) data
3) erroneous data
What are trace tables used for?
Dry running a subroutine or algorithm to make sure there are no logic errors
What is time efficiency?
The amount of time it takes an algorithm to complete a task
Define ‘machine code’.
Low-level code that represents how computer hardware and CPUs understand instructions. It is represented by binary numbers
Define ‘assembly language’.
Low-level programming language closely related to machine code
Give an example of machine code.
000000 00010 00011 00100 00000 100000
Give an example of assembly language.
ADD r4, r3, r3
Give some characteristics of high-level languages.
1) one instruction represents many instructions of machine code
2) the same code will work for many different machines and processors
3) the programmer can easily store data in lots of different structures without knowing about the memory structure
4) code is easy to read, understand and modify
5) must be translated into machine code before a computer is able to understand it
6) you don’t have much control over what the CPU actually does so programs will be less memory efficient and slower
Give some characteristics of low-level languages.
1) one instruction of assembly code usually only represents one instruction of machine code
2) usually written for one type of machine or processor and won’t work on any others
3) the programmer needs to know about the internal structure of the CPU and how it manages the memory
4) code is very difficult to read, understand and modify
5) commands in machine code can be executed directly without the need for a translator
6) you control exactly what the CPU does and how it uses memory so programs will be more memory efficient and faster
What are the three types of translators?
1) assemblers
2) compilers
3) interpreters
What are assemblers used for?
To turn assembly language into machine code
What are compilers and interpreters used for?
To turn high-level code into machine code
Give some characteristics of compilers.
1) translates all of the source code at the same time and creates one executable file
2) only needed once to create the executable file
3) returns a list of errors for the entire program once compiling is complete
4) once compiled the program runs quickly, but compiling can take a long time
Give some characteristics of interpreters.
1) translates and runs the source code one instruction at a time, but doesn’t create an executable file
2) needed every time you want to run the program
3) the interpreter will return the first error it finds and then stop - this is useful for debugging
4) programs will run more slowly because the code is being translated as the program is running