A module is another term for a separate file. If you divide a large program into subprograms and store those subprograms in a separate file, each file is a module. A module variable lets you create a variable that can be accessed only by code stored in that particular module. The advantage of module variables is that they give you the convenience of a global variable but without the danger of letting every part of a program access that variable.

 

Instead, module scope limits access only to code in that file. Although an improvement over global variables, module variables also have some of the disadvantages of global variables. If a file contains a lot of sub programs, trying to find which line of code is messing up your module variable can still be troublesome.

 

After you isolate commands inside a subprogram, your program can’t run those commands until it “calls” the subprogram. Calling a subprogram basically tells the computer, “See those commands stored in that subprogram over there? Run those commands now!” Every subprogram needs a unique name so when you call that subprogram to run, the computer knows exactly which subprogram to use. Public subprograms allow other parts of a program to manipulate an object.

𐌢