I can still remember the precise moment I first fell in love with polymorphism.
I had just delivered the final version of a medium-sized system (20,000 lines of C++) for running psychophysical visual perception experiments. The system could generate and animate a wide range of visual stimuli in 3D, using left-right stereograms viewed through LCD-shuttered glasses. It had its own scripting language and could run a controlled series of experiments, record a subject’s responses, and generate reports and statistics on the results. It had real-time feedback mechanisms. It optimized its graphics to ensure that minimal frame-rates were always met. It was just what the doctors ordered.
Naturally, I got a phone call the very next day: “It’s a great system, Damian. Works like a charm. Easy to use. Does everything we’d hoped. It’s just what we ordered. Now, could we just add…”
Of course what they wanted was an entirely new category of visual stimulus. As well as the ability to investigate stereo perception (by sending a slightly offset version of the same signal to both eyes), they now wanted to study differences in left-brain/ right-brain neurophysiology, by sending completely different signals to each eye. And could they have it by Friday?
As it turned out, they could.
The main stimulus-display subsystem was based on a tightly coded
while loop that did little more than call the
draw_me method of the current
Stimulus object. Normally, this object ...