1/102
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
Why does thinking procedurally make writing a program easier
breaks down problem into smaller parts which are easier to understand and easier to design
First stage of thinking proceduraly
Problem decomposition - large, complex problem is continually broken down into smaller subproblems. Problem becomes more feasible to manage and can be divided between a group of people according to the skill stes of individuals,
How are problems decomposed
top-down design. Breaks down problems into levels. Higher levels provide an overview of a problem while lower levels specify in detail the components of this problem
Aim of top-down design
to keep splitting problems into sub-problems until each sub-problem can be represented as a single task and a self-contained module or subroutine. Each task can then be solved and developed as a subroutine by a different person. Each subroutine can be tested separately before being integrated
Second stage of thinking procedurally
Identify the components of the solution and assess how its best to be solved. Useful to identify tasks which can be solved using an already existing module, subroutine or library. The components are combined to form a full, working solution.
What to consider when combining components to form a full solution
The order in which operations are performed is important. Some subroutines might require data from other subroutines or the user before they are able to execute, so will be unable to execute simultaneously.
What is concurrent processing
Multiple processes being executed at the same time. Each process is given a slice of processor time to give the illusion that they are happening at the same time. Different processes can be executed by different processors.
What is concurrent thinkong
the mindset that allows you to spot patterns and parts of problems where concurrency can be applied
How to determine which parts. of problems can be solved at the same time
Assess which parts of a problem are related as they can often be solved simultanesouly so can be dealt with concurrently
Difference between concurrent procesing and concurrent thinking
Concurrent processing uses a computer processor whil concurrent thinking uses your braing
Parallel processing vs concurrent processing
Parallel processing is when multiple processors are used to complete more than one task simultaneously. Concurrent processing is when each task is given a slove of procesor time to make it look like tasks are being completed simultaneously when in reality they are executed sequentially
Benefits of concurrent processing
More efficient processor use/ less idle processor time
Long running tasks do not delay short running tasks
User can interact with the computer while other tasks are running, so less time is wasted waiting
tasks requiring preconditions can wait and then resume execution
Drawbacks of concurrent processing
Can take longer to complete when large numbers of users or tasks are involved, as processes cannot be completed at once
There is an overhead in coordinating and switching between processes, which reduces program throughput
Not all tasks are suited to being broken up and performed concurrently
Explain why concurrent processing is needed to allow multiple users to log in and interact with game elements at the same time
multiple requests to the server at the same time
Server needs to respond in a reasonable time
Having multiple processors handling different requests would increase response time
Users could override each other’s changes
Programming will need to restrict access to database
Use record locking to stop edits if someone else has access to the data
Different users will have different response times
Processor can still handle other requests
So the perofrmance of other users is not affected
What is a decision
A result reached after some consideration
exmples of decisions in designing programs
Choosing the paradigm used, deciding how different pieces of information are collected, choosing programming language, input devices, output devices
How to simplify the decision making process
Limit the possible solutions. Eg which programming language is feasible to use based on its suitability to the problem, whether it provides enough functionality, how easy it is to learn given time constraints etc
decision shape in flow chart
diamond
Conditions that affect the outcome of a decision
Evaluate effectiveness, convenience, and feasibility. This might vary depending on purpose and end-users
Importance of thinking logically
allows you to plan and prepare for different scenarios as it provides foresight into the decisions made throughout the whole program. Good decision making is key to solving problmes effectively
Inputs
any data required to solve a problem
Outputs
results that are passed back once the inputs have been processed
Preconditions
requirements which must be met before a program can be executed
why have preconditions on subroutines
ensures that subroutines can safely expect the arguments passed to it to meet certain criteria. Preconditions can be tested for within the code by are more often included in the documentation
Why include preconditions in the documentation
reduces the length and complexity of the program; saves time need to debug and maintain a longer program; code is more reusable
what is caching
the process of storing instructions or values in cache memory after they have been used, as they may be used again. Very common in the storage of web pages so content can be loaded without any delay
Pros of caching
saves time as slower RAM is less frequently accessed; images do not have to be downloaded multiple times, freeing up bandwidth for other tasks
what is prefetching
when algorithms predict which instructions are likely soon to be fetched. The instructions and data are then loaded and stored in cache before they are fetched. Less time is spent waiting for instructions to be loaded into RAM from the hard disk
Limitations of prefetching
depends on the accuracy of algorithms used as they can only provide an informed prediction and there is no guarantee tat this will be right
Cons of caching
the effectiveness depends on how well the caching algorithm is able to manage the cache. Larger caches can still take a long time to search and so cache size limits how much data can be stored. Therefore difficult to implement
What are reusable program components
commonly used functions packed into libraries for reuse
Decomposition
broken down into smaller, simpler tasks
Pros of decomposition
developers can identify the program components developed in the past that can be reused to simplify the process
Pros of reusable components
more reliable as they have been already tested; saves time and money and resources; can be reused in furutre projects, saving development costs
Limitations of reusable components
May not always be possible to integrate existing components developed by third parties due to compatibility issues with the rest of the software. These components may need to be modified to work with existing software, which can be more costly and time consuming than developing them in house
define abstraction
the process of removing unnecessary details from a problem
representational abstraction
analysing what is relevant and simplifying a problem based on this information
Abstraction by generalisation
grouping together similarities within a problem tp identify what kind of problem it is
why do abstraction by generalisation
allows certain problems to be categorised as being of a particular type so a common solution can be used to solve these problems
Data abstraction
details about how data is being stored are hidden. Programmers can make use of abstract data structures without concerning themselves about how they are implemented.
Procedural abstraction
Programmers can perform functions without having knowledge about the code used to implement this functionality.. Once a procedure has been coded, it can be reuses as a black-box
Levels of abstraction
the highest levels of abstraction are closes to the user and are usually responsible for providing n interface to the user to interact with hardware. Lowest levels of abstraction are responsible for actually performing these tasks through the execution of machine code
Pros of abstraction
allows non experts to make used of a range of systems or models by hiding info that is too complex; more efficient design as programmers can focus on the key elements; less time spent coding;
why are levels of abstraction used
to handle large, complex problems by separating tasks - higher levels deal with user interaction while low levels execute machine code
what is meant by layers of abstraction in programming languages
the distinction between low-level and high-level languages - each layer hides complexity from the one above it
low level vs high level langauges
low level is closer to machine code, harder write and requires hardware knowledge; high level is easier to lear and closer to natual language and hides machine-lvel detail
how does the TCP/IP use abstration
it divides network communication itno four laters, each handlind a different function and hiding details from the others
why are standards important in layered in layered models it TCP/IP?
they ensure compatability and allow layers to work independently while following agreed protocols
abstraction vs reality
abstraction simplifies real-world entities into computational models like variables or objects
how does OOP use abstraction
objects represent real-world entities, attributes model characterisitics and methods model actions
what does designing a solution involve
thinking ahead about how different components of a problem will be handled in the best way possible
why is thinking ahead important
it helps developers anticipae potential issues and make programs easy and inuitive to use
what are the three main parts of any computations problem
inputs, processing and outputs
what are te inputs in a computational problem
data entered into a system by the user that is required to solve a problem
what are outputs in a computational problem
the results produced after the iputs have been processed
what must designers decide when handling input and ot=utput
suitable data types, data structures and methods to capture and present the solution
what order should designers consider inputs and outputs
start by identifying required outputs, then determine the inputs and processing needed to achieve them
what are preconditions
requirements that mist be met before a program or subroutine executes
what happens if preconditions arent met
the prigram may fail to run or return ivalid results
why are preconditions useful
they let a subroutine safely assume that input arguments meet certain criteria
where can preconditions be defined
within the code itself or in the documentaiton accompanying the program
what does including preconditions in the documentation achieve
reduces program length and complexity, and saves debugging and maintenance time
why do peconditions promote reusability
they ensure necessary checks are made before execution so the subroutine can be safely reused
what is caching
storing recently used instructions or data in cache memory so they can be accessed faster later
why is caching useful
it avoids repeatedly fetching data from slower secondary storage, saving time and improving performance
eg of caching
web browsers cache frequently visited pages to speed up loading and reduce bandwidth usage
what is prefetcing
a technique where alogrithms predct and preload data or instryctions likely ot be needed soon
what limits the effectiveness of prefetching and caching
accuracy of prediciton alogrithms and the limited size and search speed of cache memory
main advanatge of caching and prefetching
significantly improved performance if implemented correctly
what are reusable program components
pre-written, tested pieces of code that can be used in multiple programs
where are reusable components stored
in libraries
why is decomposition useful when designing software
it breaks the problem into smaller tasks, making it easier to identify reusable components
eg of reusable components
stacks, queues, classes, subroutines
pros of reusable components
savs time, money and resources sunce theyre already tested and reliable ; can be reused in future projects so reduces development costs
limitation of reusable components
compatability issues may arise which may require modification work which may be more costly than developing in-house
why is thinking procedurally useful
it simplifies the program design, allows easier testing and debugging, enables teamwork by dividing tasks, and makes t easier to modify and reuse components later
what is the first stage of thinking procedurally
probelm decomposition - taking the problem defined by the user and breaking it down into smaller subproblems that are easier to solve
define problem decomposition
the process of splitting a large,cimplex problem into smaller, more manageable subproblems, each which can be solved separately
pros of problem decomposition
makes the overall problem easier to manage, allows different peopple to work on different parts accoridng to their skills, and supports modular, testable program design
top-down design
involves starting with the overall problem and progressively breaking it into smaller and smaller subproblems until each can be implemented as a single, specific task
pros of top down design
It helps structure complex problems into logical levels, where higher levels show the overall structure, and lower levels define detailed tasks. This allows clearer design, independent development, and easier testing.
aim of top-down design
o keep decomposing the problem until each subproblem can be represented as a single, self-contained task or subroutine that can be coded and tested individually
what ahppens after all the components are identified
They are combined and integrated into a complete working program, ensuring that each subroutine interacts correctly with others
Why is the order of operations important when combining subroutines?
Some subroutines depend on data from others. Executing them in the wrong order can cause errors or illogical results, so programmers must plan the correct sequence of operations
when can subroutines be executed simultaneously
iProblem decomposition → Split problem into subproblems
Top-down design → Refine subproblems into simple tasks
Identify components → Decide how to implement each part
Combine solution → Integrate subroutines into a full program
Determine execution order → Arrange subroutines logically and efficientlyf they don’t depend on the same data or inputs, multiple subroutines can be executed simultaneously (parallel execution)
summarise thinking procedurally
Problem decomposition
Top-down design
Identify components
Combine solution
Determine execution order
define a decision
The result reached after some consideration
why is decision making important
it allows programmers to choose the most effective approach for solving a problem
eg of making decisions in software development
choosing the programming paradigm, choosing input and output devices, deciding how to collect and process data
how to simplify the decision making process
by narrowing down possible options based on feasibility, functionality and familiarity - eg choosing a programming language that suits the problem
why is it important to identify where decisions need to be made
so enough info can be gathered about the available options, allowing informed secisions that lead to more effective and efficient solutions
main factors influencing the outcome of decisions
effectiveness, convenience, feasibility
how to evaluate factors when making decisions
rank the factors by importance. this prioritisation hekps determine the most suitable option
what is the effect of decisions on a program’s flow
they determine the route the program follows. depending on the user’s input or internal logic, different sections of the code may execute, leading to varied outcomes
thinking logically meaning
identifying where and when decisions must be made, planning all possible outcomes and structuring the program to handle each scenario appropriately
summarise decision making
Identify where decisions need to be made
Gather information and options
Evaluate options based on effectiveness, convenience, and feasibility
Prioritise key factors
Choose and implement the best solution
Reflect on the decision’s outcome and adjust if necessary
what is concurrent processing
completing more than one task at a given time. This doesnt mean that mutiple tasks have to be done at once, it means different tasks are given slices of processor time to give the illusion that tasks are being performed simultaneously
what is concurrent thinking
the mindset that allows you to spot patterns and parts of problems where concurrency can be applied
how to fetermine the parts of the problem that can be solved concurrently
first asses which parts of the problem are relatedand these can often be dealt concurrently
difference between concurrent processing and concurrent thinking
concurrent processing uses a computer processor while thinking uses your brain