What is Abstraction Layer? You might have noticed the usage of this terminology in various technical article but ever wondered what this Abstraction Layer is? An abstraction layer or level of abstraction is a way to hide the way the things are running behind certain functionalities. The best known example of Abstraction Layer can be the OSI model for network protocols.
Basic Examples of Abstraction Layer
The byte stream input/output (I/O) model created by UNIX OS and later adopted by other operating system is another classical example of usage of Abstraction Layer. In UNIX OS, that is your OS X Mavericks now for practical example, most types of input and output operations are considered to be like streams of bytes to be read from a device or to be written to a device. This stream of bytes model is used for file I/O, socket I/O and terminal I/O in order to provide device independence. As Terminal itself went obsolete, Terminal emulation is actually done now.
In order to read and write to a device at the application level, the program needs to call a function to open the device which may be a real device such as an Optical Drive or a virtual device such as a network port or a file within the system. The device’s physical characteristics are mediated by the operating system which in turn presents an abstract interface that allows the application user to read and write bytes from/to the device. The operating system then performs the actual transformation needed to read and write the stream of bytes to the device.
Abstraction Layer : To Summarize
In computing, a level of abstraction is a generalization of a model or an algorithm which is completely independent of any specific implementation. These generalizations arise from similarities that are well encapsulated by models that express similarities present in various specific implementations. The simplification is/are provided by a good layer of abstraction which allows easy reuse and acts as an barrier to be abused.
In the above image, we have shown some terminologies, which basically can be searched on this website for more details. A typical computer user is only aware of the Application plus OS and the Hardware. The in between layers, which a general, an average user can not see (but can be made ‘visible’ in other ways) but are present. All of them are separated by Abstraction Layer. Hardware abstraction Layers (HAL) are sets of routines in software that emulate some platform-specific details, they give the programs a direct access to the hardware. There can be different types of Abstraction Layers like API level abstraction, Database Obstruction and so on.
Bad, brute example :
In order eat the chocolate, you need to first tear the wrapper, then the foil and then the real chocolate is…no! You need to open your lips, make the jaws, tongue properly aligned…after eating the chocolate (do not eat the whole bar), again you put the abstraction layers in proper places – can you eat a chocolate with the wrapper? To protect the half eaten chocolate, usually you add some ‘security’ to control the access! That is the ‘API level abstraction’. That foil has some function, it not only decorates the chocolate – this is ‘Kernel’. If the foil gets torn during packaging, the chocolate will be ‘hacked’ by weather, ants.