Abstraction is when you remove unnecessary details when modeling something.
Abstraction can be useful for many things, including but not limited to:
Abstraction has lots of advantages, such as not needing to program anything that barely effects the system and reducing time spent, or making the information layed out easier to digest. However, it does come with some negatives such as the more abstraction used, the less accurate a model may be which can reduce how well it represents the physical thing.
The map of the london underground doesn't need to show the exact path of each route, but only which line goes to which stations and in what order. This is useful for passengers as it makes the information easy to digest, however if someone needs to know the exact route for tunnel repairs for example, it will be near useless.
Thinking ahead is when you make something to be used multiple times throughout the program such as a function or subroutine to save time.
When using this method, you might want to specify:
This allows you or anyone else who might use it to know what the function needs as an input and what it outputs before actually using the function, this keeps the function easily reusable.
Linking libraries are good for this as you can use some prewritten code to do what you need such as calculating a square root, to speed up the programming process.
Caching (which is done by the OS) is another aspect of this as it temporarily stores frequently used instructions or data to be accessed quicker.
Procedural abstraction is when functions or subroutines are used to do specific tasks for you, for example drawing a triangle, giving you parameters to make any specific triangle you want, but doing all of the extra steps itself.
Procedural abstraction can have multiple layers, for example a function for
drawing a house could use a function for drawing a rectangle which then
could use a function for drawing a line, and so on.
This can create something called top-down design, where the bottom functions
can be quite complex and take a lot of programming, but are then reused to
make a simpler function and so on, building more layers of abstraction until
at the highest level a single function could be used to do something that
would otherwise take thousands of lines of code.
This is done all the time in programming as even the base langauge you might
use is heavily abstracted from the instructions the computer actually
carries out.
A good example of this is the p5.js library which is used to simplify making images with a canvas in html and javascript.