3 ms·
I won't comment on the design concerns. Many people have done that and I could swing either way on your choice of implementation strategies. Instead, I'd like t
by pjackson 18y ago
I won't comment on the design concerns. Many people have done that and I could swing either way on your choice of implementation strategies. Instead, I'd like to comment solely on the code.
As an agilist, I'd say: "The code works, so it adds business value, and therefore the rest doesn't matter." However, I am not solely an agilist. I believe this code is too hard to maintain.
This code is terse, which is often good. However, it is also too clever for me to follow in a few minutes. It's a library function, so there isn't much to gain from being terse or clever.
You could do one of several things, but here are the two I'd consider:
1. Keep the logic the way it is, and attempt to use formatting and commenting to make it easier to follow. Use more vertical lines and maybe use sidebar commenting to make each line clear in its intent.
2. Follow the advice of the folks who say that you're not really saving compiler time and unroll the logic into more definitive chunks that use variables to illustrate what you're up to.
In this case, I prefer #2, because I suspect you may have put more effort into writing fewer lines than you may have been able to put into a solution that used more lines. If you consider the cost-per-line-of-code, you may not have saved anything.
That said, congratulations. You may want to consider entering an obfuscated code content. :) (Just kidding).