# Abstraction

Breaking down code into reusable chunks can make it easier to understand. Doing so can hide background details and remove unnecessary information.

When you write programs, the code can easily become long, complex, and hard to read. So that you can break it down into smaller, more understandable chunks, programming languages let you create your own commands which you can reuse throughout your code.

### Using abstraction

Imagine you want to write a program which makes a robot wave.

To make the robot wave, you could give it the following instructions:

lift up your armopen your handmove your arm leftmove your arm rightmove your arm leftmove your arm rightclose your handlower your arm

That would be a lot of instructions to give each time we wanted to make our robot wave. It would be much simpler if we could teach it how to wave once, and each time after that we could simply give it the instruction wave. In programming this is known as ‘abstraction’. Abstraction is the act of removing complexity from a problem by hiding background detail and removing unnecessary information.

how to wave: lift up your arm open your hand move your arm left move your arm right move your arm left move your arm right close your hand lower your armwavewavewave

Most programming languages allow you to create a set of commands and label them. Using that label, you can then run that set of instructions from elsewhere in your program. These sets of instructions are often called a ‘subroutine’, ‘procedure’, or ‘function’. In Scratch, you can create your own subroutines using my blocks.

## Next step

In the next step you will create your own block to draw a shape. When you do this, you will be abstracting a sequence of commands into one new command.