Tuesday, December 8, 2009

Indirection and Parameters - Computer Science Week


This is the second post for Computer Science Week, on random topics in computer science. There is an old saying attributed to David Wheeler "All problems in computer science can be solved by another level of indirection". Kevlin Henney's corollary to this is, "...except for the problem of too many layers of indirection."

Indirection is simply something pointing to something else. It is often used to mean pointers or references in computer programming, but in a more general sense of computer science, a "handle" or a "parameter" is a mechanism for indirection. For instance, if I were writing a program to control robot, I would not want to make code to move the arm forward one inch, more code to make it move two inches. Instead, I would write code to move the arm and parameterize it to specify how many inches to move.

As long as we're doing that, why not parameterize the direction to move? Or which arm to move? Or whether to move an arm of a leg? Ultimately, indirection lets us factor out common attributes at the expense of potential complexity in a subcomponent, when the parameter is accessed and the data is "dereferenced."

1 comments:

You may lose some people with "parameterize"

Post a Comment