|
Home | About | VB Tutorials | Programming Basics | VCE & Teacher�s Resources |
||
|
|
||
|
|
|
Programming Basics
A Program�s Anatomy
The Header
The header of a program should contain information about the program (see the section on comments, later).� The header should also declare any variables that are used throughout the entire program (eg. A variable to hold the current date could be declared here) and are commonly referred to as global variables.� Any constants that are used throughout the program (eg. A constant for the number of days in a year) are also defined in the header.� Finally, a header is the place to include information about other files that may be used (this may not appear in some programming languages).
Functions
Functions also need comments to describe itself and what inputs and outputs are needed.� Functions are used to work on only a small part of the data.� They can be used to manipulate data, retrieve data, or remove data.� The less complex the function, the better.� (It is always better to split up the tasks a function performs if you can).
The Main function
The Main function is often found at the end of a program, but sometimes seen at the start.� It manages the work-flow of the program and should contain the major decision-making rules.� The main function �calls� other functions to use the data.
|
|
|
||