An overview of abstraction in General.
This article is an introduction to abstraction in general. It has been written for a larger audience and does not require any prior knowledge of computer science. Everyday life examples are used to allow the content to be understandable by as many people as possible.
This isn’t my usual hands-on guide on how to get a specific thing done in web development, it is rather just a presentation of a fascinating concept that provides lots of benefits we’ll explore.
The content presented here applies to several sciences other than software engineering. This being said, fasten your belt and let’s get started.
What is abstraction?
Abstraction can be defined as the process of hiding the complexity of a system by providing an interface that eases its manipulation.
It is such an important term in the computer world and it applies to many domains of our everyday life.
As an example, the device in your hand uses a form of abstraction. Your interaction with the very complex underlying hardware is eased by the provision of a very intuitive interface comprised of icons, keyboard, touchscreen, mouse…
In fact, in the past, computers were operated through a finite set of commands on a dark and scary screen, Each was assigned to a specific task.
You had to remember the exact command in order to operate your computer.
The veteran among you will remember the MS-DOS command prompt.
As you can see, this was counter-intuitive to non-technical people and made it hard to get anything done.
The key here to bear in mind is “finite set of commands”. A question arising from this might be:
How can one perform an operation that is not listed in the finite set of instructions available?
Well, this is where composition comes in. The trick is to be able to create a set of atomic commands, which, if composed together, can perform a lot of new operations suited to users’ needs, as unpredictable as they can be.
This would suggest that an infinite amount of problems could be solved by CLEVERLY COMBINING a finite amount of already existing commands.
This is the principle abstraction, it composes the very limited set of available commands to produce more and more complex commands to fit custom use cases.
Assuming that commands offered only the possibility to copy and delete files; moving files would simply be the composition of copying files to the desired location then deleting them from their previous location: two fundamental operations composed to solve a specific problem at a higher level, a higher abstraction.
Remember from the above that interfaces aim at hiding complexity and easing manipulation.
User interfaces with mouse and keyboards saw the light of day to provide an intuitive means of communication between the user and the computer, by providing a layer of abstraction on top of the “scary dark screen” that could only understand textual commands.
A single click over an icon could be in fact equivalent to complex commands you had to perfectly recall from memory.
The whole complexity of the computer was hidden to the user who could now easily interact with visual artifacts.
Simple application in mathematics
Another example would be one with addition and subtraction, in fact, these are fundamental, atomic, and indivisible operations in Mathematics, in the sense that they cannot be broken down into smaller chunks of operations. With these two operations, only a limited set of problems could be solved.
The need for multiplication and division needs to be considered, a composition of our finite set of commands (addition & subtraction) is required.
A multiplication becomes nothing more than a set of successive additions; And division, well, a set of successive subtractions.
In this example, multiplication and division are higher abstractions of addition and subtraction respectively.
From this simplified analogy, you could abstract addition and subtraction for something completely different if the need ever arose.
The need for exponentiation arose and the latter was defined as a set of successive multiplications.
From the latter example, we can say that exponentiation is an abstraction of many multiplications which are abstractions of many additions.
Considering abstraction levels as steps of a ladder, we can say that addition comes at the bottom, multiplication in the middle, and exponentiation at the top. These are called levels of abstraction.
Every abstraction aims at hiding the complexity of the set of operations that compose it.
No sane individual would want to perform five to the hundredth power using only a series of raw additions. It would assuredly become non-manageable. We use abstraction to simplify our work. This saves us from the pain of reinventing the wheel.
The figure below shows how dangerous chemical manipulations can be to an untrained user. Abstraction is then used by providing a friendly and safe user interface through buttons…
If a discipline, for some reason, wishes to use an operation above exponentiation, it would proceed by building a step above exponentiation which is a step above multiplication, The latter is a step above addition.
In computer science
The more we abstract, the least “generic” the resulting operation becomes, the more “specific” it gets.
As a direct consequence, fundamental operations, listed in the finite set of instruction, by their low-level abstraction, have a greater scope of flexibility than higher-level operations.
This principle applies to computer science and every programming language comes with its own level of abstraction.
Higher abstraction can mean lower flexibility and lower abstraction higher flexibility. There are pros and cons with each abstraction level, but when benefits of higher abstraction far outweigh the cost, we abstract!
With the above being said, How does abstraction work in computer science? in programming languages? what set of atomic operations is available?
Well, this is a question for another article you can read by clicking here.
Found this article interesting? leave a comment and let me know how abstraction applies in your field of study and how you benefit from it.