teach-ict.com logo

THE education site for computer science and ICT

1. Introduction

It is possible to write a simple program that does not need to think about how the program itself is put together. But once a program reaches a certain level of complexity, the programmer should put some thought into arranging the code they write in a sensible, easy-to-read fashion.

For imperative languages such as Python, C, and Java, the most natural method of organisation is the block structure.

In block-structured programming, every task the program carries out is separated into its own 'block' of code statements. This can be a section within a conditional statement like IF or CASE, or can be a loop that continues until the task is done, or it can be a subroutine set apart from the main program.

The important thing is that the block allows the programmer to work with a task largely isolated from the rest of the program. Once that code is written, it's time to move on to the next block.