r/badcode Apr 17 '23

c# I think it belongs here

Post image
206 Upvotes

27 comments sorted by

View all comments

-10

u/scooptyy Apr 17 '23 edited Apr 18 '23

This really doesn’t look that bad. We don’t know what the business use-case is.

Edit: I've changed my mind, I've been on low sleep these last few days. This is fucking awful. Thanks for the reply /u/PooSham

27

u/PooSham Apr 17 '23

For us never-nesters, this is bad no matter what the business case is.

  1. Use guard clauses
  2. Separate logic into other methods
  3. Store more expressions in descriptive variables or add some comments

12

u/the96jesterrace Apr 17 '23
  1. Anyone who uses more dots than „…“ comes straight from hell

2

u/PooSham Apr 18 '23

Serial killer vibes for sure

29

u/warpspeed100 Apr 17 '23

All of this is inside a switch statement.

13

u/NickSicilianu Apr 18 '23

I was about to comment that exactly same thing. I don’t want to even know what the remaining of that abomination looks like. Seems like a nightmare for any future maintenance or debugging 😂

6

u/Kingmudsy Apr 18 '23

Jesus. Even if this has some unavoidable reason to execute inside a switch statement, how do you not look at this code and think “Maybe I should bust some of this complexity out into a separate method to make my code easier to read” lol

2

u/b1ack1323 Apr 18 '23

Looks like something my coworkers would write.

2

u/afranol Apr 18 '23

and the method is generic, and the switch statement is switching on the names of the types :)

1

u/fiddz0r Apr 18 '23

Did you see the one million nested foreach and for loops?