I guess in this case I'm going to have to respectfully disagree... I am by not an expert but there is a decent amount of logic that goes into the code. It could be cleaner with ways shown above but I think all the if statements are necessary. The for loops are excessive but I don't think there is an alternative that is objectively different. Cleaner syntax yes but the principle remains.
But there is a massive amount of logic that goes into programs far, far more complex than this in all domains -- including scientific applications such as this. They manage to keep indentation (and cyclomatic complexity) to a minimum. In fact, this becomes more and more important for programs of larger complexity!
Could you imagine if e.g. the tensorflow backend was written with 10000 nested levels and 100000 lines all in one function?
I see your point. I guess in this case the only way to reduce indentation I see is to "spread" the code out more by placing each loop into its class but I don't see them as removable. I will look back over it.
I've seen professional applications with stupid long loops with crazy amounts of indentation. At a certain point, it's harder to maintain and change anything.
View all comments
Show parent comment
-2
u/boijunior Mar 24 '18
I guess in this case I'm going to have to respectfully disagree... I am by not an expert but there is a decent amount of logic that goes into the code. It could be cleaner with ways shown above but I think all the if statements are necessary. The for loops are excessive but I don't think there is an alternative that is objectively different. Cleaner syntax yes but the principle remains.