3 ms·
"Avoid Indirection in Code" is a foolish thing to advocate, and the example provided is more confounding than explanatory. Abstraction is the key. Abstraction
by JackFr 7y ago
"Avoid Indirection in Code" is a foolish thing to advocate, and the example provided is more confounding than explanatory.
Abstraction is the key. Abstraction can be used to reduce incidental complexity by hiding an implementation. Abstraction can be used to reduce the cognitive load of the essential complexity by making the code look like the problem domain.
But there is a cost to abstraction. A person reading your code may not have the same mental model of the problem, and might’ve be working at a higher or lower level of abstraction, in which case the "indirection" might be a stumbling block. Weigh these costs carefully.