1/69
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
data type definition
any values that can be taken by the program, or the operations which can be performed on it
Data types
integers
real/float
Boolean
character
string
date/time
pointer/reference
records
arrays
integer
whole number, can be positive or negative
includes zero
real/float
positive/negative values, can have a fractional part
Boolean
A value which is either true or false
Character
A single letter or symbol
string
a collection of characters
date/time
ways of storing a point in time
pointer/reference
used as stores for memory addresses of objects created at runtime i.e. dynamically
records
collection of fields, each can have a different data type
arrays
finite, index set of related elements with same data type
user-defined data types based on language defined(built-in) data types
derived from existing data types to create a customised data structure
ensures solution is as memory efficient as possible
variable declaration
giving a variable a name/data type
allocates memory
constant declaration
constant does not change
Assignment
giving constant/variable a value
Iteration
repeating an instruction, could be definite or indefinite
selection
comparing values and choosing action accordingly
subroutine (procedure/function)
‘out of line’ block of code containing set of instructions to perform a frequently used operation
executed by writing it’s name in a program statement
three combining processes basic to all imperative programming languages
sequence
iteration
selection
definite iteration
number of repetitions known before loops starts
indefinite iteration
number of repetitons unknown
nested selection/iteration
one placed within another
identified with indentation
why is it important to use meaningful identifier names
sensible and easy for others to understand
integer division, including remainders
MOD - modulus
when are relational operations used (=><)
used in iteration, selection structures, and for base cases in recursion
advantages of using named constants
easier to understand, clear
e.g. hrrate= 14
hrworked=input
PAY=hrRate*hrworked
easier to update in one place
random number generation
built in function
takes seed value and uses series of mathematical operations to arrive at a number
pseudorandom
exception handling
when the wrong data type is used
computer handles exceptions to avoid crashing by pausing execution and saving the current volatile state on system stack before running a catch block
the catch block stops crash and informs user of error
parameters of subroutines
arguments
used to pass data within programs
function
subroutines that return a value/ valyes
local variables in subroutines
exist only when the subroutine is executing
are accessible only within the subroutine
more memory efficient
global variables
accessible from any part of the program
exist in memory for the duration of run
local can be given the same identifier, can change local while global stays the same
how are stack frames used in subroutine calls
stores:
return addresses
parameters
local variables
for each subroutine call
useful with nesting, each popped when finished
recursive techniques
subroutine defined in terms of itself
base case in recursive techniques
stopping conditions - if not, stack overflow
simple problems using recursion
factorial
binary search
programming paradigm
procedural/functional programming
object-oriented programming
procedural-oriented programming
formed from sequence of instructions executed in the order that they appear
data stored by constants and variables
procedural-oriented programming - components
assignment
sequence
selection
iteration
procedural-oriented programming - design/adv.
Top-down design
broken down into smaller tasks
allows for testing of each individual component
able to split between teams/team members
navigation improved → maintenance easier
procedural-oriented programming - hierarchy charts
graphically represents the structure of the program
procedure = rectangle
class
blueprint for objects, defines property/attribute fields that capture the common behaviours and characteristics of objects
object
one class can have many objects
methods across classes can be the same but value of the objects is unique
methods will have private(only accessed within object), public allow interface for accessing and modifying a class
Instantiation
class created
inheritance
allows one class to share properties and methods of another, while having own
Association
Object forms part of it’s container object
aggregation
composition
Aggregation
Weaker, associated object will still exist without other, e.g. passengers in a car
composition
stronger, destroyed together, e.g. wheels of a car
Polymorphism
objects processed differently depending on their class
overriding
if method has same name as method in inherited class but different implementation
unified modelling language - composition and aggregation
composition → represented by black diamond line
aggregation → white diamond line
why is the object oriented paradigm used
clear structure
development and testing easier
divide tasks in team
reusable blocks increase space efficiency
object oriented paradigms
encapsulate what it varies
favour composition over inheritance
program to interfaces, not implementation
encapsulate what it varies
any requirements likely to change should be encapsulated into a class
favour composition over inheritance
composition is more flexible but isn’t always appropriate
allows unrelated classes to make use of similar methods
program to interfaces, not implementation
collection of abstract procedures that can be implemented by unrelated classes
abstract methods
blueprint for methods that must be implemented by subclasses
virtual methods
base case that can be overridden, allows subclasses to provide specific implementation
static methods
belong to class rather than instance
types of specifiers in oop
public
private
protected
class diagram symbols for specifiers
public → +
private → -
protected → #
dynamic data structures
can be expanded given limitation of available memory