41
I read in some places about programming that something does or should do an indirect.
What is this and what it’s for?
41
I read in some places about programming that something does or should do an indirect.
What is this and what it’s for?
36
It is the act of making reference to something indirectly, that is, through something other than its value. It is a form of delegation. We use it in programming all the time without realizing.
One variable is an indirect. We could access a memory position, but we use a name that leads us to that memory position. This gives a very large flexibility, we can even change the memory address of this variable and it remains the same reference. Not that it’s always possible, but it’s a possibility.
One function is another of the most used. The function is nothing more than a name that references a memory position where it has a code. The direct use is to access the code right there, but what we do is indicate where the code is. It’s an indirect access, so it’s an indirect.
A delegate is an indirect of the indirect. It is a more complex variable or object that has an address where it has the information that indicates which function is to be executed, so it is an indirect level on top of another.
The polymorphism (at least one of the types) is another form of indirect indirect, since to know what to call, you need to consult a table of what should be executed. The first reference is where the table of that type is and then takes the reference to the correct method.
A object in dynamic memory is an indirect because you access a value that indicates where the object is.
When you do not know the size of the object until its creation during execution, you need to create an indirect, which is very common in strings.
A array simple is an indirect. It functions as a variable of a variable. The primary variable is the array as a whole, the secondary variable is its individual element.
A array of miscellaneous objects can do an indirect for compatibilization of types. In fact this applies to any structure. A dynamic typing language does this.
You know the famous getters and setters? It is an indirect where a function is used instead of a variable. We already know that the variable is an indirect. The function is another type of indirect being used for a specific purpose of new abstraction.
A class or method takes an object to parameterize it. This object is the one that has the concrete implementation that the class or method needs. Inversion of dependency is just one more example of indirect.
Dynamic linkage need the indirect to make the connection.
These are just a few obvious examples.
The indirect may avoid conditional deviations which may have a high processing cost.
In general indirect occurs through a pointer, even if it doesn’t look like a.
With it we produce more code DRY. You have the information in one place and can make several references to it.
OOP uses and abuses indirect. Especially when using the famous design patterns created to solve the problems that OOP has caused. The indirect comes to save the homeland.
Indirect can occur at more abstract levels. The use of a library, a webservice, of a driver, everything can be an indirect. Access to memory and all hardware by applications is an indirect. Access is indirect through an intermediary mechanism made available.
The indirect is fundamental to create abstractions, from the simplest, as the variable, to the most complex. It is so important that it is called "Fundamental Theorem of Software Engineering".
There is no problem in computing that cannot be solved with an extra level of indirect
-- David J. Wheeler
Actually the phrase became famous in Butler Lampson’s hand. So the quote is an indirect... :)
It is obvious that there are exaggerations in its use, because in general we do not think much about the indirect, we are just looking for a solution to the problem. We don’t think about not causing another problem. When you delegate too much you start to duplicate efforts and start to increase complexity. So it is customary to complement the above quote with:
... except for the problem of too many levels of indirect
Browser other questions tagged terminology software-engineering computer-science
You are not signed in. Login or sign up in order to post.