APCO 1P93 Lecture Notes - Lecture 6: Local Variable, Global Variable, Code Reuse
Document Summary
A module is a group of statements that exists for the purpose of performing a specific task. Most programs are large enough to be broken down into several subtasks. Divide and conquer: it"s easier to tackle smaller tasks individually. Benefits of using modules: simpler code, code reuse. Small modules easier to read than one large one. Can call modules many times: better testing. Test separate and isolate then fix errors: faster development. Reuse common tasks: easier facilitation of teamwork. Smaller, simpler code is easier to maintain. The code for a module is known as a module definition. To execute the module, you write a statement that calls it. A module"s name should be descriptive enough so that anyone reading the code can guess what the module does. The statements within a module: a header, a body. A call must be made to the module in order for the statements in the body to execute.