GPS - Tue Feb 26, 2002: Often times I think about what is the perfect example to demonstrate a way of doing something with Tcl. The common thought I have is whether or not to make the code reusable or to make things more clear through less reusability. I can recall that when I was first starting to program I was frequently frustrated by people using variables rather than values in examples. It seems like having more than 2 variables in a complex proc was too much for me. Introducing upvar and uplevel into the idea is akin to trying to teach someone how to use pointers (which is often confusing to new programmers).
With some of my examples I have hardcoded paths rather than represented a widgets path with a variable, simply because I feel it makes it more understandable when trying to grasp a new concept. Another thing to consider is the relative ability of the viewer.
Somewhere along the way I developed the ability to store more variables in my mind when reading source code (I still have problems with recursion though). Is there a method to help programmers train their minds for this kind of task? Perhaps this is like advanced math, but more broken down into parts. Are there any books dealing with training your mind to handle general complex ideas? Do most programmers visualize the objects or data in their heads? Is visualization the key?
What are your thoughts about this?