r/programminghorror echo "Sub Mod" && :(){ :|:& };: 16d ago

Java Too much nesting

Post image
72 Upvotes

10 comments sorted by

48

u/orkeilius 16d ago

At least is easely solvable with early return

1

u/KeyIllustrious587 7d ago

I can do it with fewer blocks without guard clause
First, i combine entitydatamanagers with && to save 1 nest, then i combine all player condition checks with && to save 2 extra nests
Now we get 7 nests instean of 10
Then i combine getCurrentAction with aO timer to squeeze another extra nest
Now we got 6 nests.

Still many, but at least it looks less cursed.

16

u/darkalemanbr 16d ago

Average code inside a Lua loop

7

u/Carmelo_908 15d ago

At least this is easily fixable by extracting function and inverting ifs with a early return

5

u/ElectricalPrice3189 14d ago

Some hates "&&"

5

u/ApocalyptoSoldier 14d ago

Someone has never heard of early returns or logical and

1

u/KeyIllustrious587 7d ago

i heard about it, but og devs does not

3

u/DontRelyOnNooneElse 16d ago

Eh. I've seen a lot worse. It's not great but I wouldn't call it a horror. 10 nested ifs is at least somewhat grokable. Try 50. That's where true abomination lies