←back to thread

159 points todsacerdoti | 1 comments | | HN request time: 0.204s | source
1. wcrossbow ◴[] No.40716816[source]
It is kind of obvious but I think it is worth mentioning out loud regarding whether how to classify something as essential or accidental complexity is that where it ends up falling is only easy to tell in hindsight. Recently I finally realized, after working for almost 3 years in a problem, that it could all be framed as graph problem. This simple change of frame dissolved hundreds of lines of code into `reduce(find_shortest_path(graph, start, end), some_op)` style single lines. Now I understood that what I was previously doing was manually crafting paths through this informally defined graph across nodes I knew had connections. The ratio of comments to code was about 5:1 to make sense of it. Before that I believed all of it was true essential complexity but looking through the right glasses it really wasn't. The lessons for me (some of which I seem to have to constantly relearn) where:

1. It may only look complex because you are not thinking about it in the right way. 2. The right data structure/abstraction has the power to turn the worst spaghetti into a shining beacon of simplicity.

An important corollary is that if it looks complicated is probably because you don't understand it yet. Tautological yes, true, also :D

Not trusting myself on what is essential complexity and insisting on hitting my head against the wall until I found a solution has served me well many times in my life and career.