Abstraction
abstractionThe process of extracting or withdrawing something. is the process of filtering out - ignoring - the characteristics of problems that are not needed in order to concentrate on those that are needed. It is also the filtering out of specific details. From this, we can create an idea of what is to be solved.
Abstraction allows us to create a general idea of what the problem is and how to solve it. The process instructs us to remove all specific detail and any patterns that will not help us solve our problem. This helps us to form our idea of the problem. This idea is known as a 鈥榤odel鈥.
Consider the problem of creating a program to calculate the area of shapes. The problem could first be decomposed into modules, each of which would be a particular shape, for example rectangle, square and triangle. Abstraction can then be followed for each module.
For example, for the rectangle module the first step would be to notice that all rectangles share general characteristics:
- a width
- a height
- area = width 脳 height
When abstracting, certain details are discarded but others are kept:
- all rectangles have a width, but for the program design the actual rectangle width is not needed
- all rectangles have a height, but for the program design the actual rectangle height is not needed
- area is always width 脳 height
To solve this problem, all the program needs to be able to do is receive a width and a height, then calculate the area from those numbers. The actual numbers are irrelevant - they change with every rectangle - so they are discarded.
A similar abstraction can be carried out for each module, resulting in a program with self-contained subroutineA section of code written outside of the main program. The umbrella term for procedures and functions. and clear interfaceThe part of a computer program with which the user can interact..
An example of abstraction is the London Underground map. It details tube and rail lines and the stations that are on them. That is all that is required for a passenger to be able to plan a journey from one station to another. Other details, such as real geographical location, distance between stations, depth underground and number of platforms, are not included as they are irrelevant to journey planning on the Underground.