← Back to context

Comment by throwaway2037

5 years ago

I know that I'm late to this party, but what would Clean Coders think about algorithm heavy weight code like "TimSort.java"[1]? (This is the Java port of the famous Python stable sort.) Since Java doesn't have mutable references (pointers) or allow multiple return values, it gets very tricky to manage all the local variables across different functional scopes. I guess you could put all your locals into a struct/POJO, and then pass it around to endless tiny functions. (Honestly, the Java regex library basically does this... sucessfully.) Somehow, I feel it would be objectively worse if this algo code were split into endless 1/5/10 line functions! (Yes yes, that is an _opinion_... not a fact!)

Come to think of it, is the original C code for Python's timsort equally non-Clean Code-ish?[2] Probably not!

[1] https://github.com/AdoptOpenJDK/openjdk-jdk11u/blob/master/s...

[2] https://github.com/python/cpython/blob/main/Objects/listobje...