1/14
Topic Flashcards
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Abstraction
The process of removing unnecessary detail
Simplifying a complex problem
allows programmers to focus on only the core/necessary parts
(used in networking and higher and lower level programming languages)
Benefits of Abstraction
Allows programmer to focus on core aspects so reduces programming time/cost as faster to create the program. Factors that detract from the program can easily be ignored.
Simpler to solve the problem/ Simplifies the problem as easier to solve/understand
Program requires less memory/computational power/faster program execution
Reduces complexity of programming code so can run on lower spec computers
Completed program will be simpler for end-users to understand
Program more likely to solve the problem as unnecessary aspects will not detract from the main purpose of the program.
Why are reusable program components used in programs?
One piece of code can be used many times in multiple places, which makes code more efficient.
No need to write the same code multiple times.
Takes less time to plan/design/code the program.
Easier error detection since if you fix once, it is corrected in every place where that code is used. Less likely to have errors as code is not written multiple times.
Easier to maintain the program.
How to describe logical decisions within a program
Decision, action the program will take if true, action if fals
Global variables
Created when program starts, all subroutines can access/update its contents.
Stored in memory throughout the whole code execution. If the amount of data stored in them is large, then would make program memory intensive.
Used when variables are needed throughout the game.
Local variables
Created in the subroutine they are created in, not accessible directly from any othr subroutine
Removed from memory once subroutine ends.
Can be passed as parameters to a function to be updated, and then returned to override the original local variable.
Can be passed by reference to a subroutine to allow the content of the variable to be updated.
Concurrent processing
Processes happen at the same time/ processes overlap
One process can start before another one finishes
Each process is given a slice of processor time
Different processes can be executed in parallel by different processors/cores
Benefits of concurrent processing
More efficient processor use/ Less idle time for processor/ Greater throughput
Long running tasks do not delay short running tasks
Tasks requiring preconditions can wait and then resume execution
User is able to interact with the computer while other tasks are running
Drawbacks of concurrent processing
If lots of users are requesting for tasks to be completed, it takes longer for everyone to complete their task
Why concurrent processing is needed to allow multiple users to log in and interact with game elements at the same time
Game could have large number of requests to the server at a time, and the server needs to respond in a reasonable time. Having multiple processors handling the different requests would increase response time.
Users could override each other’s changes, so use record locking to stop edits if someone else has access to data.
Different users will have different response times, therefore the processor can still handle other requests so that performance for other users is not affected.
Why is there a need for concurrent processing
Processes are happening at the same time/ at overlapping times. One process may need to start before a second has finished. In terms of an online ticket system, individual processes are threads, each thread has a life line. One request is sent to the server, this will have a thread.
Multiple requests to the server can be made at the same time. Programming on server will need to allow multiple threads to manipulate a list of requests. Programming will need to restrict access to the database, and will allow those reading and writing to manipulate at the same time. Record locking will need implementing- more complex programming.
Will allow for multiple access to the website at the same time by different customers, and will allow for multiple ticket sales for the same event without selling the same seat twice.
Thinking Ahead
Consider inputs/outputs
Data Types
Data Structures
Order of data
Advantages of including preconditions within the documentation accompanying a subroutine
Reduces length of program
Reduces complexity of program
Saves time needed to debug and maintain a longer program
Makes subroutine more reusable
Caching
The process of temporarily storing a copy of instructions or values in cache memory after they have been used, as they may be used again. Reduces the time taken to fetch them again.
Advantages of caching webpages
Content can be loaded without delay
Images and text do not need to be downloaded multiple times
Frees bandwidth for other tasks on a network
Less time spent waiting