3 ms·
This is pretty similar to what happened to me. I was implementing an algorithm that had multiple parts and the data would arrive asynchronously. The first time
by trendia 9y ago
This is pretty similar to what happened to me. I was implementing an algorithm that had multiple parts and the data would arrive asynchronously.
The first time, I wrote the multipart algorithm using a functional style to encode each state. As the algorithm grew, it became more and more difficult to reason about and managing dependencies between the parts was harder, not easier.
When this became unwieldy, I rewrote it. However, when I wrote it the second time, I wrote the algorithm in a way that made it appear imperative. Everything was linear, starting with part B, then part C, etc. A small backend managed state, but you could read through the algorithm code and it almost seemed like it would run synchronously.
The second method was easier to read, debug, and modify. I will probably not go back to the functional method anytime soon.
- simplify 9y agoBe weary of "programmer's rewrite bias". Anything you rewrite is likely going to be easier to read, debug, and modify since you understand the problem better the second time.
- kqr 9y agoAlso the first version may have had post-release bugfixes etc which are frequently omitted from the rewrite and then rediscovered later on.