The danger of this approach is that as the program gets large, it is difficult to keep track of which routines are changing the common data and how. This makes the program difficult to modify and prone to bugs.
If done well, this can solve the problem of not knowing how each routine changes the common data. The problem with it is that it requires a great deal of information to be copied. The programming language Pascal typically uses this approach.
For an example, see the code included in the assignment. The main program declares two variables, bigSpenderNames and competitorCustomerNames (click for location in code). Each of these consists of an integer and twenty strings. The routines in the module StringList modify these variables. (The data type StringList.listType is defined in the module StringList, but this does not allocate any memory. Note that this type is exported by the module so that main program can uses it.)
Pointers are a key tool in the programming language C. People just learning to program often find passing pointers to and from routines causes them grief. To avoid these problems, OOT handles this automatically. When a formal parameter in a procedure is not of a simple type (eg char, integer, or pointer), then instead of copying the value of the parameter into the procedure, a pointer to the data structure is passed. The first question of this assignment will give you some understanding how pointers are passed.
The code included in the assignment includes an example of this. The module Transactions allocates the data structure Trans. This is data is not exported. Hence, the main routine has no access to it, except via the routines that are exported.
The disadvantage of having the data local to the module is that the main routine is restricted to having only one instance of this module. In contrast, the main routine allocates space for two lists of strings, bigSpenderNames and competitorCustomerNames, which can be passed to the same module StringLists.
The example code includes two modules, StringList and TransationList . Each module handles a single list, one of strings and the other of credit card transactions. Other then this difference, the code for the two modules are very similar.
A main part of this assignment is to write a single class of object called IntList. This will have all the code for handling lists. You will also write the derived classes that inherits everything from IntList except what it is a list of.