2.1.1Thinking abstractly +2.1.2 Thinking ahead Flashcards
Abstraction
Hiding unnecessary detail and showing details that are important in context.
Inputs
What the system needs to process.
Outputs
What the system should produce.
Preconditions
Conditions that already exist and could affect how you devise a solution to a problem.
Subroutines, Procedures, functions and methods
Blocks of code that perform a task and can be reused multiple times.
Caching
Storing instructions or values in cache memory after they have been used, as they
may be used again. Results in faster retrieval times, as instructions or data don’t need to be fetched from secondary storage, which is much slower.
Prefetching
Data being requested from main memory by the processor before it is required.
Procedural abstraction
The process of breaking down problems into smaller more manageable steps
Data abstraction
a form of abstraction in which details about how data is being stored are hidden
Functional abstraction
the implementation detail of the computational method is hidden
Problem abstraction
the process of filtering out - ignoring - the characteristics of problems that are not needed in order to concentrate on those that are needed
The difference between abstraction and reality
● Abstraction is a simplified representation of reality
● Real-world values can be stored as variables and constants
● Objects in object-oriented programming are an abstraction for real-world entities
○ Attributes represent the characteristics of an object
○ Methods represent the actions a real-world object is able to perform
2 advantages of abstraction
-easier for programmers to focus on the core elements
-reduces the time needed to be spent on the project
-prevents programs from getting unnecessarily large
what is representational abstraction
a technique in which excessive details are removed to arrive at a representation of a problem that consists of only the key features.
what form of abstraction involves grouping together similarities within a problem to identify what kind of problem it is
abstraction by generalisation
what kind of problems make use of multiple levels of abstraction
large complex problems
give two applications of layers of abstraction
-Networking(TCP/IP)
-programming languages
state 2 advantages of using abstraction in programming languages
-easier to remember syntax in high level languages as it is closer to natural language
-coding becomes accessible to beginners
how does object oriented programming use abstraction
-objects are an abstraction for real world entities.
-Attributes are an abstraction for the characteristics of an object.
-methods are an abstraction for the actions a real world object is able to perform
what is the purpose of thinking ahead
to make programs easy and intuitive for users to use
what three considerations do programmers need to make inputs and outputs when thinking ahead
-method of input/output
-data structures used
-data types used
-order of data
where can pre-conditions be defined
within the code or within documents
give an example where preconditions are required
-stack functions
check that the stack is not empty when popping an element from a stack.
check that a stack is not full when pushing an element onto a stack
-Factorial function
the number passed to the function cannot be negative
state two advantages of including preconditions within the documentation accompanying a subroutine
-reduces the length of the problem
-reduces the complexity of the program
-saves time needed to debug and maintain a longer program
-makes subroutine more reusable
how is caching used to store web pages
web pages that a user frequently accesses are cached, so the next time one of these pages is accessed, content can be loaded without delay
what are the advantages of caching web pages
-content can be loaded without delay
-images and text don’t have to be downloaded again multiple times
-frees bandwidth for other tasks on a network
-less time is spent waiting
give a limitation of caching
-accuracy of algorithm used
-effectivness of algorithm in managing the cache
-size of the cache
Give 3 advantages of using reusable program components
-more reliable than new components. As they have already been tested
-as developing from scratch is not required, this saves time, money and resources
Give two examples of reusable programs
-abstract data structures
-classes
-subroutines