大象传媒

Abstraction

is the process of filtering out - essentially 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, an idea of what is to be solved can be created.

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 form our idea of the problem. This idea is known as a 鈥榤odel鈥.

Consider the problem of how a program might be required to calculate the area of any rectangle. 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 input a width and a height, then calculate the area from those numbers. The actual numbers are irrelevant - they change with every rectangle - and so are discarded.

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.

A section of the London Underground map