The variable window

The variable window is designed to display the variables that are declared within the program. Since any large program will have far more variables than can be sensibly viewed at one time, a means had to be devised to limit the list of variables in some logical way. The means I decided to use was to list the variables by scope. That is, the user can choose any scope and view a list of the variables that are declared within that scope.

To display the scopes that are available, the program displays a graphical scope tree (see Figure 4.6). This tree, with a node for every scope, is displayed with the outermost scopes at the top; thus, a new user sees the global scope first. A large program will have very many scopes, and so the user can choose which scopes should be displayed. Clicking on any node with the left mouse button expands the node, so that its children are displayed. The navigator stores the state of each node, so if any of those children were expanded in previous operations, then their children will be displayed when the parent is expanded. Scroll bars are provided because the diagram is likely to become very large. To help cut down on the size of the tree, subtrees are pruned if they don't contain any declarations--otherwise, every for loop, while loop, etc. would have its own node.

The navigator attempts to label nodes with some meaningful identifier: each file has its own node labelled with the filename, and function scopes are labelled with the name of the function. Other scopes are given the generic label ``Local Scope''.

Figure 4.6: The variable window
\begin{figure}\centerline{\psfig{figure=varwin.ps,width=13cm}}
\end{figure}

The user can click on any node in the tree and a list of the variables declared in that scope will be added to the right hand side of the window. The user also has the option to make the list include all the variables visible within that scope (i.e., include variables from all the ancestors of the scope). If the user clicks on a name in the list, the program will highlight the node that represents the scope in which the variable was declared. This allows a user who has come across a previously unknown variable in the code to work out where it was declared. The fact that the scope tree is displayed graphically enables the user to see easily where else the variable is likely to be used in the program, since it is visible to all nodes in the subtree with its declaration scope as root. If a user is considering making changes to the code that affect the variable under consideration, then this knowledge about what other areas of the code could be affected is crucial, and the graphical display enables decisions to be made very quickly.

Matthew Exon 2004-05-28