Problem solving and programming Flashcards
(36 cards)
Alpha testing (at least 4 properties)
Testing within the development company //
testing by the developers
Testing it in the way the end user would
Used when the program is complete
Used when white box/black box/system etc.
testing is complete
Takes place before Beta testing
Advantages of global variables (2 x AO1, 2 x AO2)
Simpler to program …
… because values do not need to be
passed/renamed/moved between different
subroutines
Do not need to worry about returning values //
do not need to decide between byval/byref …
… all parts of the program can access the
(same) value (in the same way)
Disadvantages of global variables (3 x AO1 and 3 x AO2)
Uses more memory …
… because the memory space is declared when the program starts and remains in use throughout (negligible for small programs)
Makes testing / debugging more difficult …
…. as it’s difficult to test an individual block of code
Reduces data accuracy / integrity …
…. changing a global variable may have an impact on another module
IDE for debugging (AO1 and AO2, at least 3)
-Debugging tools (variable watchers) allow inspection of variable values, this can allow run-time detection of errors
-Code can be examined as it is running, which allows logical errors to be pinpointed
IDE debugging can produce a crash dump, which shows the state of variables at the point where an error occurs
-It can step through code, which allows the programmer to (watch the effects of each line of code and) check variables
-The insertion of a break-point, allows the program to be stopped at a predetermined point in order to inspect state of variables
What is a function
-A function is a named section of program (1) that performs a specific task (1).
-It returns a value (1), it is often called inline (1).
What is recursion
The function calls itself from within the function
Recursion > iteration
-More natural to read (1)
-Quicker to write / less lines of code, (1) as some functions are naturally recursive (1)
-Suited to certain problems (1), for example those using trees (1)
-Can reduce the size of a problem with each call (1)
Recursion < iteration
-Can run out of stack space / memory (1) (due to too many calls (1)) causing it to crash (1) This can be avoided with tail recursion (1)
-More difficult to trace / follow (1) as each frame on the stack has its own set of variables (1)
-Requires more memory than the equivalent iterative algorithm.
-Usually slower than iterative methods (1) due to maintenance of the stack (1)
Difference between global and local variables
Global variable is visible throughout a program / may be accessed from more than one part of the program (all subroutines) (1), local variable is visible only in module construct where it is created / declared (1)
Properties of local variables (at least 3/4)
-Local variables are created in the subroutine they are
created in, they are not accessible directly from any
other subroutine
-Local variables are removed from memory when the
subroutine ends.
-Local variables can be passed as parameters to a
function to be updated, and then returned to override
the original local variable
-Local variables can be passed by reference to a
subroutine to allow the content of the variable to be
updated
Black box testing
Checks that given inputs give the correct output
No understanding of the code (not looking at the code)
White box testing
Understands the structure and logic of the program
Each line/path of code is tested
Inspection (testing)
During a meeting a small team will read through code
Analysing it with a checklist which list the common problems
What is IDE (integrated development environment)
A single program (1) used for developing programs (1) made from a number of components
When must a global variable be used
A global variable used where a value needs to be accessible from various parts of a program (1 – AO 1.2), it is the same value (1 – AO 1.2).
Irrespective of the place where it is accessed (1 – AO 1.2).
e.g. today’s date, VAT rate, pi (1 – AO 2.1).
Functions vs procedures
A function returns a single data type value (1), whereas a procedure can pass back many values (1) by parameter (1)
A function can be used in line (as part of a statement)
A function can be used as a variable
A procedure is used as any other program instruction
What is a variable
A memory location
That stores data/a value
That can be changed
OOP - what is a class
A class is a template (1) used to define methods and attributes (1) used to make objects
OOP - what is inheritance
Inheritance is when a child class takes on all attributes (1) and methods (1) from a parent class (1). The inheriting class may override some of these methods / attributes (1) and may have additional extra methods and attributes of its own (1)
OOP - what is encapsulation
Encapsulation is the process of keeping an object’s attributes private so they can only be accessed and changed via public methods
OOP - what is an object
An object is an instance of a class
OOP - what is an instance
An instance is a specific occurrence of a class
OOP - how to make attributes private (python)
Double underscore after the dot
e.g. “self._ _name = name”
OOP - what is polymorphism
Polymorphism means that objects of different types can be treated in the same way