Abstraction layer

From Free net encyclopedia

An abstraction layer is a way of hiding the implementation details of a particular set of functionality. Perhaps the most well known software models which use layers of abstraction are the OSI 7 Layer model for computer network protocols, OpenGL graphics drawing library, and the byte stream I/O model originated by Unix and adopted by MSDOS, Linux, and most other modern operating systems.

In the Unix operating system most types of input and output operations are considered to be streams of bytes being read from a device or being 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. In order to read and write to a device at the application level, the program calls a function to open the device which may be a real device such as a terminal or a virtual device such as a network port or a file in a file system. The device physical characteristics are hidden by the operating system which presents an abstract interface which allows the programmer 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.

Most graphics libraries such as OpenGL provide an abstract graphical device model as an interface. The library is responsible for translating the commands provided by the programmer into the specific device commands needed to draw the graphical elements and objects. The specific device commands for a plotter are different from the device commands for a CRT monitor but the graphics library hides the implementation and device dependent details by providing an abstract interface which provides a set of primitives that are generally useful for drawing graphical objects.

See also

de:Schichtenmodell

pt:camada de abstração