O'Reilly logo

DarkBASIC Pro Game Programming, Second Edition by Joshua R. Smith, Jonathan S. Harbour

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Dividing and Conquering with Functions

Functions are important for breaking up a large program into smaller, more manageable pieces, leading to better code reuse and legibility. They are also important for creating program logic. Quite often, the conditional statements in a branching statement point to a subroutine to keep the branching statement short. If each case in a branching statement included a page of source code, it would be easy to lose track of the cases! Therefore, functions are essential parts of a programming language. Figure 4.2 illustrates the relationships between the main program and all of its functions, which are broken down into more detail at each level.

Figure 4.2. Structured programs have a hierarchy of functions from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required