Tcl is an embeddable and extensible computer language developed by John Ousterhout [Ousterhout90][Ousterhout93]. Tcl is frequently used with the rapid prototype paradigm of system development because it is so well suited to developing solutions when the specific requirements are unknown. [Sarachan95] In this paradigm, users and developers grow to understand the problem and solution as the project develops. The downside to this paradigm is that code may need major revisions during the development cycle, at the cost of man-hours, and possibly code robustness.
Standard software engineering techniques such as modularity and code
libraries are extremely useful in keeping such a project under control.
Tcl supports these techniques with the
commands. There are also certain coding techniques specific to Tcl
which can be used to reduce the need for maintenance during a project's
In this paper I discuss some of the Tcl language constructs that I used in the evolution of the TclTutor package.
TclTutor is a computer aided instruction package for teaching computer programming languages. The goal was to create an engine which could be used to provide instruction and interactive examples for a number of computer languages. The first course of lessons to be released were written for Tcl. Example lessons have been written for courses in Tk, Perl, and Java. As a proof that the design could be extended I wrote a few small quizzes and substituted a quiz checking program for the language processor.
TclTutor has evolved in the past 2 years from a set of scribbled notes taken during a 1995 panel on teaching using Tcl [Crowley95] to a package of 42 lessons that runs on all flavors of Unix (tm), Win 95 and Win NT. Much of the evolution has been driven by user requests as they (unwittingly) and I developed this solution to the problem of learning a new programming language.
Since the meat of a tutorial package is in the lessons, not the engine, I put special effort into developing an engine that could be easily extended, allowing me to spend my time writing lessons, not modifying the base code.
The constructs that I used in this package can be grouped into a few categories:
The maintenance of state information and handling of command line options are relatively trivial constructs, but will be discussed briefly because they are applicable across almost all projects. These constructs allow modifications to the state variables without modifying the code for maintaining state or parsing command lines.
The lesson and course selection constructs are used to create menus at run time. These constructs allow the addition of new courses or lessons with no modifications to the code which builds the menus.
Example processing frequently requires custom procedures to parse input, set command line options, select language processors, etc. Given those requirements, new code must be written to support each new language. The design of TclTutor allows this language-specific code to be contained in a separate file, which is only accessed as required.