4.1 Fundamentals of Programming Flashcards
What is the role of a data type?
To define which computations/operations may be carried out on the bit patterns.
2016 Additional A-Level paper 1
What is meant by a recursive subroutine? [1]
A subroutine that calls itself;
2016 Additional A-Level paper 1
State two items that will be stored in a stack frame for a subroutine call [2]
1) Return address
2) Parameters
Additional answers: Local variables, Return value
2016 Additional A-Level paper 1
State one reason why many programmers follow the design principle:
“favour composition over inheritance”. [1]
**Easier to test each class using unit testing ** // with composition each
class can be tested separately but it is not possible to test a subclass
independently from the base class;
There can be unintended side-effects for derived classes if a method in
the base class is altered;
Composition is more flexible as if a new class is developed it can easily
be used instead of the class that currently is used in the composition;
MAX 1
2016 Additional A-Level paper 2
Describe the relationships association aggregation and composition aggregation, making it clear what the difference between the two is. [2]
Composition and association are both “has a” relationships –
An object contains another object;
With composition if the containing object is destroyed so are the objects
it contains, this is not the case with association;
Name 3 OOP design principles
1) Encapsulate what varies
2) Program to interfaces, not implmentation
3) Favour composition over inheritence
Name 2 advantages of “programming to interfaces, not implementation”
1) Makes it easier to edit code in the future
2) Makes it easier to test each class individually.
2017 A-Level Paper 1
Explain the differences between static and dynamic data structures. [2]
Static data structures use a fixed amount of memory, declared at run time.
Dynamic data structures can grow and shrink as necessary.
static data structures have storage size determined before program is run; dynamic data structures can grow/shrink during execution / at run-time;
Static data structures can waste storage space/memory if the number of data items stored is small relative to the size of the structure; dynamic data structures only take up the amount of storage space required for the actual data;
Static data structures have fixed (maximum) size; whereas size of dynamic data structures can change;
Dynamic data structures (typically) require memory to store pointer(s) to the next item(s); which static data structures (typically) do not need; NE. Dynamic data structures use pointers
Static data structures (typically) store data in consecutive memory locations; which dynamic data structures (typically) do not;
MAX 2
What are the advantages of using Object Oriented Programming? (OOP)
Allows for modular code
Easier to test individual classes
Allows for code reuse
What is a ‘constant’
A variable that keeps the same value whilst the code is being run. It cannot be updating during run-time.
What are the advantages of using recursion?
It can lead to short, elegant code
Sometime recursion is the only way to solve a problem
Sometimes people think recursively
What are the disadvantages of using recursion?
> Can take up memory space
Can take a long time for larger values
What error may occur if a recursive subroutine never meets it’s base case?
Stack Overflow error.
What are the advantages of using local variables?
Local variables cannot be changed by code in other subroutines
Names of local variables can be repeated in other subroutines
Reduces overall complexity of debgugging the program
What are the characteristics of a high level language?
> Problem oriented
Uses Syntax similar to human language
High levels of abstraction
Translated into machine code for the computer to process