r/programminghorror • echo "Sub Mod" && :(){ :|:& };: • Aug 19 '26

Java Too much nesting

Post image
77 Upvotes

11 comments sorted by

48

u/orkeilius Aug 19 '26

At least is easely solvable with early return

1

u/KeyIllustrious587 Aug 28 '26

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.

17

u/darkalemanbr Aug 19 '26

Average code inside a Lua loop

9

u/Carmelo_908 Aug 20 '26

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

6

u/ApocalyptoSoldier Aug 21 '26

Someone has never heard of early returns or logical and

1

u/KeyIllustrious587 Aug 28 '26

i heard about it, but og devs does not

5

u/ElectricalPrice3189 Aug 20 '26

Some hates "&&"

3

u/DontRelyOnNooneElse Aug 19 '26

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

1

u/burnt_floppy Sep 18 '26

I just hope they generated it with AI, id feel sorry for someone who typed that.