3 ms·
Regardless of the language, the function is too complex. Every while could be it's own function and now you have a bunch of simple unit tests. Unit tests are l
by Supermancho 5y ago
Regardless of the language, the function is too complex.
Every while could be it's own function and now you have a bunch of simple unit tests. Unit tests are literally the double accounting for the logic, which is the value.
Any unit tests for that code is going to be horrendous to get decent coverage...and this is how it's easy to know it's too complex. Functions, especially if they are small, can be considered free, given the JVM inlines them into branches anyway....but I understand this is a hot path. If you want to avoid re-allocation, Java gets into your way. You could split up the function and use a singletonClass for holding the array, without having to pass the array by value and still being able to reference the singletonClass...blah blah blah.
> Uncle Bobbing this type of code doesn't make it much clearer
I get it and agree, while still recognizing the problem. Not you not the code not me. Java.
It's really unfortunate that Java has damaged programming practices so subtly and completely by being unnecessarily byzantine AND pushing horrible solutions like Spring.
- marginalia_nu 5y agoI don't subscribe to the notion that every branch of every function needs to be tested. That just seems like anxious waste of time, not even considering the gargantuan pile of additional work it creates in maintenance of the tests.