Abstraction is the use of patterns to project hidden concepts. It is one of the foundation principles of software engineering. ABSTRACTION in software engineering hides implementation details. Programs are written in high level language but computers do not understand high level language, computers understand low level language. A programmer does not have to learn low level language ( programs written in 0’s and 1’s), this is an example of abstraction as programmers write programs in high level language and it gets converted into low level language. This conversion is an abstraction and it is hidden from programmers.
In software design there exists many levels of abstraction. When a solution to the problem is given in terms of the problem environment it is treated at the highest level of abstraction. When solution to the problem is given in the form of procedural orientation then this is a lower level of abstraction. When a solution to a problem is given in such a way that it can be directly implemented then it is the lowest level of abstraction.
In software engineering the solution to the problem is given using problem environment terminology and when the source code is generated it is treated as the lowest level of abstraction.
In procedural abstraction the solution to the problem is given in the form of a sequence of instructions. These sequence of instructions specifically project functions to be implemented. Terminology is the main concept of procedural abstraction as a single term may be used to signify a sequence of instructions.
When the programmer knows the output of the procedure but does not know the techniques to be used to achieve desired output. This is an example of procedural abstraction.
In C++ procedural abstractions are implemented using functions. In C++ functions manipulate data and implement an algorithm. Some of the inbuilt functions of C++ such as sqrt, pow etc, take input work on it and return the result. The internal working of these functions/procedures is not known to the programmer thus it forms procedural abstraction.
The procedural abstraction is achieved by writing programming instructions having variable parameters. Through procedural abstraction the program can modify its behaviour according to the number and type of parameters. Through procedural abstraction the programmer remembers procedure names and number of parameters in that procedure and at the time of programming it becomes easier for programmers to use it.
In C++ function overloading is an example of procedural abstraction. Through function overloading two or more functions will have the same name but different parameters. Function overloading enhances readability of programming instructions. Function overloading is used so that one function can perform multiple tasks and it can be easily remembered by the programmer. In C++ polymorphism is an example of procedural abstraction. In polymorphism function can perform different operations based on the number and type of parameters. For example,
add(int a , int b)
add(int a, int b, int c)
both procedures have the same name, “add” but one procedure takes two parameters and the second procedure takes three parameters. This is an example of procedure abstraction.
A data abstraction provoid description about a data object. Attributes that define data objects are identified and recorded. Thus, data abstraction deals with the attributes of data objects. Data abstraction is used by procedural abstraction to design abstraction. Data abstraction hides data and functions that manipulate data. Class used in C++ is an example of data abstraction. Class has a specific name and it encapsulates data member and member functions. Classes hide implementation details. In software engineering stack, queues, trees etc are all examples of data abstraction.
Data abstraction is used to design databases. The database is built using complex data and relations. The user which uses the database does not have to know about the complexity of the data and its relation or it can be said that it is hidden from the user by data abstraction. With the help of data abstraction only that part of the database is made available to the user which is required to perform manipulation tasks.
With the help of data abstraction database design is simplified. Normally database management systems apply three levels of abstraction – first, Physical level, Second, Logical level and third, View level.
In database management system data abstraction at physical level is the lowest level of abstraction. Data abstraction at the physical level decides the way the data will be stored in the database. Data abstraction at physical level describes the entire database.
Data abstraction at the logical level describes the relationship between the data and data tables. Data abstraction at logical level is less complex as compared to data abstraction at physical level.
Data abstraction at view level defines different views. As the database is accessed by different users each user can be given their own view which will be different from other user views. Data abstraction at view level is easy to implement as compared to data abstraction at logical or physical level. For example if a database contains 8 tables and there are two users then one user can view three tables and the second user can view only four tables of the same database and can have the impression that they are working on separate databases.
Control abstraction is responsible for performing control mechanisms during program execution by hiding internal details. Control abstraction mechanisms are used in Operating Systems. In an operating system semaphore is used to synchronize activities of different processes. Another example of control abstraction is Divide and Conquer technique. In Divide and Conquer a problem is divided into sub-problem this sub-problem is further subdivided into sub-problem this process continues until a sub-problem is obtained which can not be further sun-divided. This process of sub-division is carried-out by implementing control abstraction.
Control abstraction in C++ is implemented by if-then-else statements, loops such as while, do-while and for and procedure function call and return. In low level language control abstraction is implemented by Jump statements such as unconditional jump and conditional branch and Jump to subroutine such as subroutine call and return from subroutine.
Database synchronization is an example of control abstraction. Through control abstraction in database management system database consistency is ensured. When inert, update or delete operation is performed on two or more tables of the same database then consistency is achieved using control abstraction. Control abstraction uses asynchronous communication and queues to maintain database integrity. If-then-else and loops are used in stored procedures of structured query language to implement control abstraction.
Semaphores in Operating Systems is an example of control abstraction. Semaphore is an integer value that is used in critical section regions. When two or more processes are required to operate on the same file than to maintain consistency semaphore is used but the user has the abstraction that they are working on their own version of their file. Thus, semaphore is the way of achieving control abstraction.