Copyright © by Mark Baker 1996
For non-trivial programs, you can say that:
A data structure is an organised collection of atomic data items. An array or a linked list are examples of data structures. A string is also a data structure, since it is an organised collection of characters. Turbo Pascal has a string data type, which is used in a similar way to the other atomic types (integer, char, etc.), so this point has to be emphasised carefully, to avoid confusion. Arrays and linked lists can be used to implement other more specialised data structures, such as stacks and queues, but it is up to you to program them so that they behave properly (eg. with a queue, new items can only join at the back of the queue and items can only leave in order, from the front).
This exercise gets the students to create a simple address book, using arrays. One array is used for the names, another for the addresses and a third one for the telephone numbers. The following techniques will be introduced:
When writing new programs, students should be encouraged to program data entry first, followed by saving and loading. This allows some trial data to be entered and saved early on, which can then be used to test the other features as they are written. Some students waste a great deal of time, constantly entering the same test data, over and over again, because their program is unable to save anything.
When editing, students should be encouraged to implement algorithmic structures that allow the user to stop editing at any point, without having to go through every single field in a record, for example. The better ones could be encouraged to enter data into dummy variables and to copy them into the main data structures when editing is completed and the changes are accepted. This allows an ABANDON option to be offered, which leaves the main data structures unchanged.
Those who finish ahead of the class can be got to program record selection using a moving cursor, or by highlighting the appropriate record, instead of by entering the record number via the keyboard.
Groups seem to reach a stage, usually around 4-5 months into the course, when you start to get lots of long, silly error messages and unnecessary embelishments. Some of the students are starting to think that they are pretty good programmers. This usually happens around the time that they are working on their first "useful" program, which is normally the address book. It is time to bring them back down to earth, so I show them my Programming Continuum diagram, explaining that the exercises that we started off with, such as writing their name on the screen 5 times, come into the "Really Naff" category. I then point out where I think their programs lie on it (usually well over to the left!).
I then explain why their programs are still less than useful and this usually develops into a very positive discussion, on what constitutes a useful program (useful processing of data, data storage, comprehesive validation, etc.), the need to do as much work as possible for the user, the need for good, concise communication with the user, and so on. We also examine what characterises professional programs. What makes this such a useful exercise is that by this stage the students are starting to acquire the skills that allow them to produce much higher quality work, but being funny or finishing each exercise as quickly as possible is often the main aim! This focuses their attention on the quality of their work and seems to motivate them to make the additional effort required.
Teaching Programming I
Teaching Programming II
Teaching Programming III