Ask HN: What are ways programmers "reframe" problems to make them easier?
I write shaders and I often use HSL colour space rather than RGB. This solves a few problems: keeps contrast ratios consistent (by keeping luminance, L constant). Adjusts hue, H, whilst keeping the colour palette in harmony.
It also means I need only modify 1 value rather than 3.
What are other ways in which programmers reframe problems to make them conceptual easier and the implementation more straightforward?
4 comments
[ 3.1 ms ] story [ 23.3 ms ] threadIn physics for example, Lagrangian mechanics[1] is an interesting reframing of classical physics allowing for drastically simpler implementations in certain cases, while still just being a bunch of partial differential equations and numbers.
In engineering and signal processing, the Laplace transform reframes time-varying signals such[2] that it's much easier to calculate or design the resonse of a system.
Back in programmer land, several such useful reframings that aren't directly rooted in physics or linear algebra that I can think of come from crossing the functional-imperative border.
Another is inversion of control[3], in the general sense[4], where you pass the code modifying the behavior, rather than explicitly drive the modified behavior from the outside.
[1]: https://en.wikipedia.org/wiki/Lagrangian_mechanics
[2]: https://en.wikipedia.org/wiki/Transfer_function
[3]: https://en.wikipedia.org/wiki/Inversion_of_control
[4]: https://martinfowler.com/bliki/InversionOfControl.html
Here's another one: coordinate space (e.g object, world, normal, tangent) to make vertex transformation calculations almost trivial.