Question

I've read this quote in a book:

There is no problem in computer science that can't be solved using another level of indirection.

Can someone explain that? What does "level of indirection" mean?

From what I understood, indirection is a fancy name for using a pointer of a value instead of the value itself. Please clarify this for me.

Was it helpful?

Solution

"Indirection" is using something that uses something else, in its broadest sense.

So your example, using a pointer of a value instead of the value, fits this definition at one level. The pointer is the something and the value is the something else.

Typically this is something larger in scope:

  • Using a web site to graphically display the data generated by an XML based service. Here the web site is the something and hiding behind it is the data which is the something else.
  • Using an operating system to access the display screen. Here are two layers, at least of indirection. The OS uses the screen driver. One something using a something else. Then the screen driver talks directly to the screen hardware causing it to make tiny dots of light here and there. The driver is the next something using the something else which is the hardware.
  • It is not uncommon for one API to deal with something on a high level and that API deals with the same thing on a lower level. Again a level of indirection is added on top of the low level API and we call it the new, improved API.

This last example, perhaps, explains the "why" of it all.

As we work with something we master it and learn how to abstract it to a higher level of abstraction, thus a new level of indirection is needed and we can solve bigger problems faster by offloading some of the work to the new API.

OTHER TIPS

One of the potential big advantages of indirection is reduced coupling. It's another way of saying that things should be compartmentalized appropriately. This often helps significantly with testing, maintainability, and flexibility over the long term.

As an example, if your application needs to read some persisted data, instead of having the specific knowledge of where (and how) to read it scattered all throughout the application, you isolate it (put that reading of data into a method) and then let all of the other parts of your application call that method to get the data instead of each part of the app having to deal with those details itself.

Great question! I actually came across this term level of indirection in my database course. The slides for this course does not even provide any information regarding 'indirection' or how to use it, but it challenges students with a question like this: ... suppose the file is unordered by the non-key field DEPTNUMBER and we want to construct a secondary index on DEPTNUMBER with one level of indirection that stores record pointers.

Your understanding mentioned makes the subtle thing clear to me: From what I understood, indirection is a fancy name for using a pointer of a value instead of the value itself. enter image description here

Here I attach a picture in the question to illustrate. The so-called level of indirection is nothing but some blocks of memory containing pointers, which is a bridge between the indexes and the data. So here, instead of having one index for each record in the data file, it uses an aditional layer composed by pointers, making the indexes between the index file and the level of indirection(block of record pointers) sparse. And my understanding for this is it offers a good trade-off between memory usage and look-up speed by having a sparse(non-dense) index as well as a dense index for a unordered data file.

Unfortunately I could not manage to find a good explanation for the term level of indirection with respect to its implementation for database on the internet while my school's slides is just trash(it does not even cover it but they make questions with it).

Please comment if you have a good source or if I have mistaken with anything here. I would really appreciate that!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top