[Unit 2.2] Problem Solving and Programming Flashcards
Algorithms and Programming
define constant
a label to represent a value stored in memory that cannot change while the program is running
define variable
a label to represent a value stored in memory that can change while the program is running
define casting
changing a value from one data type to another
define global variables
can be accessed anywhere in the program. They must be stored in memory for duration of execution
define local variables
can only be accessed in a certain part of the program. Usually local to a subroutine and declared within.
Why don’t we use global variables?
they use a lot more memory. its harder to locate errors as global variables can be updated anywhere
difference between implicit and explicit casting?
implicit there is no loss of accuracy (int->long)
Explicit there may be loss of accuracy (double->int)
define sequence
program is followed one instruction after another
define Selection
Decision is made based on state of Bool (if..else)(switch..case)
define Iteration
repetition of a section of code using a loop
difference between count and condition controlled loop
count controlled runs a set number of times
condition controlled runs till a condition is met
difference between a pre and post check on a condition controlled loop
pre check - condition checked at start of loop
post check - condition checked at end of loop
define Function
subprogram that usually returns a value
define procedure
subprogram that performs some operation but does not return a value
define Parameter
variables that the subroutine receives (variable in the sub)
define Argument
variable that you pass into the subroutine (variable in the program)
define by value parameter
variable is copied, changing the value in the sub doesn’t change the original value
define by reference parameter
subroutine works with the original data/variable. If it changes, it stays changed
define Recursion
When a subprogram calls itself.
key features of recursion (2)
base condition (stop the loop)
recursion statement
(Dis)advantages of recursion
Dis:
-less efficient
-uses more memory
-may overflow stack due to too many calls (crashes)
-difficult to trace
Ad:
-quicker to write
-easier to read
-some problems are naturally recursive
Features of IDE (9)
syntax highlighting
code editors
debugging tools
RTE
version control
automatic line numbers
keyword highlighting
automatic formatting
autocomplete
define syntax highlighting
checks and highlights syntax errors
define code editors
write and edit code
define debugging tools
tools help you find errors
define Run time environment
runs program, converting source code into machine code, executed by CPU
define Version control
records changes, allowing you to roll back to previous version if you make major mistake
define automatic line numbering
provides line numbers in margin of your code
define keyword highlighting
colours applied to code as you write
define automatic formatting
formats code for readability (e.g. indentations)
define autocomplete
tries to predict what programmer wants
define Iterative testing
during development of program
define Final testing
after program is completed
Types of test data
normal
boundary
Invalid
erroneous
What is erroneous test data
out of the bounds of validation, should not be accepted
What is invalid test data
data of the wrong data type, should not be accepted
What is boundary test data?
data at the limit of acceptability, should be accepted
What is abstraction in terms of OOP
objects only reveal internal mechanisms relevant for other objects. Hiding unnecessary code
What is encapsulation in terms of OOP
objects do not have access to this class nor authority to change. but can call public functions.
what is inheritance in terms of OOP
objects with slight differences share code. child class inherit from parent class
what is polymorphism in terms of OOP
subroutines are flexible, depending on object.
what is instantiation in terms of OOP
creating an object from a class
what is a constructor
method that runs when class is used to create a new object
what is “public” in terms of OOP
attributes and methods that can be accessed outside the class
what is “private” in terms of OOP
attributes and methods that are not accessible outside the class (allows for encapsulation)
define “programming paradigm”
programming style used to create computer programs
what is the difference between procedural & OOP
OOP groups values together and subroutines as objects
Procedural does not link values together