367
Anon died on the "clang format bad" hill
(lemmy.nz)
Welcome to Programmer Humor!
This is a place where you can post jokes, memes, humor, etc. related to programming!
For sharing awful code theres also Programming Horror.
It has to do with how you decompose problems. In the example I gave, I was trying to point out that arithmetic average, geometric average, and normalization are related problems. Consider applying this technique to something more complicated than averages: pathfinding. You could create a dozen different efficient functions, each with different considerations, but the core of the algorithm will always be the same. You can write pathfind_land(src, dest), pathfind_sea(src, dest), pathfind_air(src,dest), pathfind_sea_and_land(src,dest) etc. but it's obviously better to write it as pathfind(src,dest, is_traversable) and select the most efficient implementation inside the function. It also allows you to use a not-optimized implementation automatically if you haven't made an efficient implementation.