Computer Science

Information Hiding

Information hiding is keeping the design details hidden behind a standard interface.

Consider the pocket calculator. There is a fairly standard keypad and small screen arrangement on most simple calculators. Anyone familiar with the device is likely to be able to operate a calculator that they haven't seen before. The keypad and screen are the interface that is used for communication with the user. The workings of the calculator are normally behind plastic cases and are hidden from the user. The user does not need to know how the calculator works in order to use it - they just need to be familiar with the standard interface.

In the field of computing, this same principle applies to hardware and software. A deep understanding of the inner workings of the computer is not required to be able to operate the computer. The same operating systems are used on many different computers to operate a wide range of different hardware. The operating system is the interface between the user and the machine. So different objects can have different implementations but the same interface.

In object oriented programming, objects are only known about through their interfaces. The interface doesn't reveal anything about the implementation of the object. In the OOP section, you will see that fields in a class are normally private, and therefore not visible/accessible to programmers using the class. The methods of the class provide a programmer with an interface through which the fields become accessible.

Many complex machines are made up of components. Each component connects to the others via standard connections or interfaces. By doing this, it becomes possible to manufacture the machine parts separately, varying the way the component works but keeping the same interfaces. Your PC or laptop is a perfect example of the principle.

In software design, this approach allows development to be divided into modules. The modules can be developed separately without the programmers of each module having to know the detail of the other modules, only what those modules might be used for by the programmer. It is easier to maintain, change and further develop a system because the changes can be made in a single location - they are local to the module. The remainder of the system remains unchanged as long as the identical interfaces are retained.


There are many examples of abstraction in our lives that we take for granted, When we look at a map, we are looking at a representation of the real world that misses out non-essential details.

In computing terms, abstraction is about getting to the heart of a problem, solving the problem and finding out which other problems can be solved using the same method.


Generalisation is a type of abstraction. In one sense it means to categorise the different details of the solution to a problem. In the hierarchy chart below, the Pythagoras probem is broken down a little.

hierarchy chart

Think about the program you would write. If you had to work with these as your headings, you might see Find b2 as requiring you to,

  1. Declare an integer variable to store b
  2. Prompt the user to enter a value for b
  3. Make the variable b equal to the user's input

The other things on the same layer could equally be broken down into the individual programming steps required to accept the user input, solve the problem and output the result.

If you consider the difference between high and low level languages, you can see how abstraction is at work. For each low-level statement, there is an equivalent machine operation. A high-level statement may result in several machine operations. As a high-level programmer you cut out the non-essential details of the process, freeing up your focus on the problem that needs to be solved.

Structured programming is a development of this principle. The program is logically divided into modules, each module performing a specific role within the program. Interfaces between the modules are clear so that local changes are possible without having to rewrite chunks of the program. OOP extends this idea further.

Data Representation

When solving a problem, we often need to find a way to represent the data that we want to store about the problem. If you look at the puzzle-related pages on this web site, you can find solutions to puzzles like the Rubik's cube. It may interest you to know that people who solve the cube for speed refer to sequences of turns that they perform as an algorithm. Letters and symbols are used to represent the 6 turning faces of the cube and the direction in which they are turned. Algorithms can be written out in shorthand form, like the following algorithm,

R F D2 B2 D U' R' B' L2 R2 D' U2 B2 D U L2 R' B' L2 F R' B' L R2 F' D2 U R2 U F

This sequence was generated from a computer program in order to scramble the cube into a random starting point. Most people who solve a cube in a minute or less are likely to be able to perform these moves as they read them - like someone sight reading in music. Cube faces are represented by the letters, R(right), L(left), U(up), D(down), F(front) and B(back). Each turn is a clockwise 90° turn of the face represented by the letter. If it is followed by an apostrophe, an anti-clockwise turn is made. A 2 after the letter indicates that the face should be turned through 180° - a half turn.

The letters can be used to represent the small cubies (there are 26 - 8 corners, 12 edges and 6 centres). A corner needs 3 letters - eg UFR (upper front right corner). An edge needs 2 letters eg UF - the upper front edge. The centre pieces don't move in relation to one another, they are fixed to the core of the mechanism. Using this system, you can assume that the following represents a solved cube,


Go to to see this in a 2d projection of a cube.

Changing the way that the letters are written allows for a short description of the state of a scrambled cube. This can be fed as input into a program that searches for optimal solutions to the puzzle from that position. These are described to the user with the notation used earlier to describe the algorithms. This is the way that the ACube program by Josef Jelinek (RubiksCube.Info) accepts input. This is a superb program and an excellent web site.

The program will convert this input into another representation. A series of integer arrays is used to store the location and orientation of the corners and edges of the puzzle. There are many other useful items of information stored about the puzzle but too much to go on about. The point is that a complex problem needs a way to represent data about the problem.

For a simpler example, go to the Floppy Cube Project pages in the C# console section.

You can get a clearer sense of how this applies to Computing in the most fundamental sense by considering the abstract data types like linked lists, queues and stacks. Think about how they are used in programming to solve represent data in solutions to different types of problem.