paper 2 Flashcards
representational abstraction
removing excessive details to arrive at representation of a problem with only the key features
abstraction by generalization
grouping together similarities in a problem to better understand the issue, allows better categorization and the application of common solutions
data abstraction
nuisances in data are hidden to allow the application of common data structures, without focusing on the details of data
procedural abstraction
using functions and library without knowledge of how the code is implemented - used in psudeocode and decomposition as procedures are reused as black boxes
multilevel abstraction
in complex problems - highest levels of abstraction are closest to user, responsible to interface - lowest levels responsible for performing functions through execution
non expert use of abstraction
hide complex or irreverent parts to allow more people to understand code
design uses of abstraction
allows for more efficient designs - allows developers to focus on necessary elements rather than worrying about the details - prevents program from becoming too large and wasting development time
layers of abstraction in programming
lower level languages difficult to write, abstracted to high level languages it is easier to write as it is closer to english
levels of abstraction in networking
TCP/IP abstracts data transition into 4 parts - makes them simpler to program and understand - layers are independent but must return a common format
caching
storing commonly used instructions and data in ultra fast memory in, on or next to the CPU - decreases fetch time - common on commonly used web pages
prefetching
an advanced form of caching, algorithms predict what is likely to be fetched soon and loads it to cache - decreases idle time whilst waiting for fetch
limitation of caching
- prefetching can fetch wrong item clogging up RAM and offering no benefit
- effectiveness depends on cache algorithm
- large caches take a long time to search
- difficult to implement
reusable program components
commonly used functions and procedures are commonly packaged as libraries - allows reuse without rewriting functions
+ promotes more efficient design as procedures are planned and packaged before hand
+ increased reliability - better testing and bugs encountered sooner
+ saves time money and resources + reused in other projects
-can cause compatibility issues when using third party libraries - requiring refactoring of code
recursion
where a subroutine calls itself until a certain condition is met - same result as iteration but suits some problems better
+ fewer lines of code - less prone to errors
- can create infinite loop if end condition never met
call stack
each time a recursive function is called a stack frame is added to the call stack containing the parameters, local variables and a return address - allows the subroutine to return to a given point when complete - once the stop condition is met the subroutine unwinds through the stack frame
disadvantages of recursion
- inefficent use of memory
- can cause stack overflow if called to many times
- difficult to trace
scope
the section of code a variable can be referenced in
local scope
variables with limited scope - only accessed in certain blocks of code - multiple variables of the same name can coexist in different sub routines - good practice to make sure subroutines are self contained
global variables
variables accessible by the whole program - variables declared in the main function automatically set to global scope - not recommended as they can be unintentionally overwritten or edited - requires more memory as only deleted when program terminates not subroutine
modular programming
spliting large programs into smaller self-contained reusable modules - increases readability, simplifies testing and maitenance
top-down approach / step wise refinement
problem is continually broken down into sub problems until each can be represented as a single self contained black box subroutines, either functions or procedures
procedures
a named subroutine which performs a specific task - it does not have to return a value but can return multiple - typically uses parameters for manipulation data points
functions
a named subroutine that performs a specific task - must return one and only one value - commonly uses local variables for manipulation of data points
parameters passed by value
a copy of the value is passed and treated as a local variable, it is discarded once the subroutine is completed - it odes not effect values outside of the subroutine