2.2.1 Programming Techniques Flashcards
What are the three programming constructs? (3)
Sequence (1) branching (1) iteration (1)
What is programming in sequence? (1)
Instructions run one after another (1)
What is iteration? (1)
Repeating instructions or code until an end result is achieved (1)
What is branching (1)
Choices that cause an algorithm to begin executing a different sequence of instructions (1)
What are the key features of recursive algorithms? (4)
Recursive functions call themselves (1) Recursion requires memory in the stack (1) Each recursive call adds new variables to the stack (1) Recursion often expresses a problem in fewer lines of code (1)
Compare recursion to iteration (4)
Recursion uses more memory than iteration (1) Recursion declares new variables each call while iteration uses the same variables (1) Recursion can run out of memory while iteration will not (1) Recursive functions call themselves while iterative ones don’t
Compare global to local variables (4)
Global variables are retained in memory permanantly (1) while local variables are cleared from memory when module exits (1) Global variables can be accessed from anywhere in memory (1) while local variables can only be accessed within their module (1)
What is the difference between byref and byval? (2)
byref refers to the location of the variable. Changes made change the original variable (1) byval takes a copy of the variable. Changes are made to the copy (1)
What is a module / subprogram? (1)
A repeatable section of code (1)
What is the difference between a procedure and a function? (2)
A function returns a value (1) a procedure does not (1)
What are the advantages of coding using sub programs? (4)
Small sub programs are easier to code / modify (1) Each sub program can be called multiple times (1) Avoids repeated code (1) Can reuse in other programmers (1) Tasks can be given to other programmers to complete as sub programs (1).
What are the advantages of coding with an IDE? (4)
Likely to include editor (1) compiler (1) and run time environment (1) May have autocorrect / autocomplete (1) May have debug features like breakpoints and stepping (1)
What are the key features of objects? (4)
Objects have a constructor (1) attributes (variables assigned to instance) (1) methods (subroutines assigned to instance) (1) Can be encapsulated (1)
What is the difference between public and private attributes? (4)
Private attributes can’t be accessed from outside of the instance (1) while public attributes can (1). Private attributes are usually accessed through a get method (1) while public attributes can be accessed directly.
What are get and set methods in classes? (2)
Get methods retrieve a private attribute (1) Set methods assign or change a private attribute (1)