What is Abstraction?

Symbol's are abstractions of the items they represent. This icon represents a general "bird", but does not give any details about the type of bird, its natural habitat or other qualities of it's existence.
Abstraction is a concept which can be summarized as the systematic removal of details from an idea or concept to either generalize it or make it easier to understand. It is easier to understand abstraction by looking at different examples. Symbol's are abstractions of the cause or object which they represent (see the bird symbol above and the caption beneath it). Word's are also abstractions of the concepts or objects they are trying to describe. Let us take for example to word "bush." While you may be able to create an image of what a bush looks like, you image will be completely different from that which another person would come up with. Biological details will vary depending on what environment you are personally most comfortable with. The word represents the general framework of the plant as being round and short, but does not provide details on the type of bush, quantitative details about how tall or round the plant is, or qualitative details such as color. Therefore the word "bush" is an abstraction because it removes these details and much more in order to generalize/allow you to categorize a whole variety of plants.

Illustrative examples of the point made in the previous paragraph
Abstractions are especially important in computer programming, where many details are left out at first in order to make programming seem accessible to beginners. This is especially evident in drag-and-drop languages where blocks are used instead of text to create programs. Languages such as App-Inventor and Scratch are drag-and-drop languages which use abstractions to make programming complex items seem simple. Take for example the "play sound" block in the image below (it's somewhere in the middle). You can probably logically already break the process of accomplishing this task into steps. Here is a simple three step process which you may have thought up:

  1. Retrieving the audio file
  2. Having the program which "plays" the sound parse the sound (analyze it)
  3. Connect to the computer speakers 
  4. Play the sound. 

While the steps are involve more technicality than this, it is obvious that the "play sound ___" block is not just one isolated step. It is a process which has been abstracted into a single block in the programming language.

Each of these blocks is an abstraction inside of the scratch interface. They all have more complex underlying commands broken down into steps which perform the processes inside of the block. 
Programming abstractions are also present in text languages. In all languages though abstractions are usually created with "methods." Methods are processes which the user creates which are then summarized in a single block/line which can then be called upon by the user with either a block or a line of text (depending on whether the language itself is block-based or text-based). Method's exist in programming languages because they allow users to create their own abstractions. Take a look at this example below which is again in Scratch. Once the method is created, then it can be called upon whenever that one block is called without needing to copy-paste the other sequence of blocks.

An example of abstraction with a simple movement program in Scratch
Once you understand that all blocks in a languages are methods either built into the language or fundamentally in the computer, then you will begin to realize why programming languages are just abstractions of abstractions. If you want to understand why an abstraction works, then you will need to look at the details of the process or idea behind the symbol, word, or summarization. Here is a final example of abstraction in python using def_ functions.

Note that the only thing which happens in the first run is that a method is called. The "def main()" and "def make_sites(n,p)" are methods which abstract the processes which are occurring behind them. Anyone who puts these methods/uploads them to their program can use it without understanding the underlying reasons for why it works. They only really need to understanding how to call the function and what the output will be. In this case the "def main()" runs the different components of the whole program (this is only part of it, their are another 83 lines which are not shown....). The "def make_sites(n,p)" creates a 2d matrix of dimension n and then populates it with a random amount of 0s and 1s based on the site vacancy probability inputed during the main function.


No comments

Powered by Blogger.