r/shittyprogramming • • Aug 02 '15

epic nesting

Post image
396 Upvotes

43 comments sorted by

72

u/[deleted] Aug 02 '15

This has to be generated right?

54

u/needshumor Aug 02 '15

I checked the top of the file for the telltale generated-by x line , but didn't see it. But that was my first thought too

0

u/[deleted] Aug 03 '15

[deleted]

28

u/DigiDuncan Aug 03 '15

Generated by someone who used a generator which provided the line, but removed the line to make it look like he did more work than he did.

5

u/t3hcoolness Aug 03 '15

This is most likely what happened.

25

u/[deleted] Aug 03 '15

6

u/Reelix Aug 03 '15

We have a "ui.js" for pretty much our entire site (Inherited from a third-party)

Currently sitting at 5,110 LoC

8

u/namtab00 Aug 03 '15

Heh peasant, I have a 6000 loc webforms page behind that I wrote... Truly ashamed of it, but the shame fades in front of the fact that none of my colleagues or management see anything wrong with it...

23

u/Protuhj Aug 02 '15

Of course there's no comments. Good luck!

1

u/rafark Jul 28 '24

Comments lie

16

u/FearAndLawyering Aug 03 '15

A nest fit for Big Bird.

23

u/mrbaozi Aug 02 '15

Sweet Jesus! Maybe I'm missing something here, but why are all the conditions the same? Wouldn't this code simpy execute the first or last if statement?

23

u/gchpaco Aug 02 '15

There's a whole bunch of callbacks; the conditions could possibly have changed. But it's still pretty bad.

8

u/ZugNachPankow Aug 02 '15

Some functions could alter htmlEncodeRegEx or iContextTo, in which case the conditions would no longer be the same.

Or they could throw errors or otherwise disrupt the control flow.

Or they simply need to be called in sequence, which is the reason why "callback hell" is a thing. This doesn't seem like callback hell, though, because there's no err being passed.

14

u/RenaKunisaki Aug 03 '15

htmlEncodeRegEx

Already a bad sign.

4

u/[deleted] Aug 03 '15

Isnt this the definition of callback hell?

1

u/ZugNachPankow Aug 03 '15

I don't know, either someone has a very particular programming style, or they don't follow the callback standard (error first, then results).

1

u/[deleted] Aug 05 '15

Yes.

29

u/steamruler Aug 02 '15

Set tabspacing to two spaces, crank your IDE coloring to the max, and start digging through it.

8

u/Booyanach Aug 03 '15

no

4 spaces

25

u/[deleted] Aug 03 '15

4 spaces is for code that's legible with 4 spaces. Ideally, that's all of your code.

This code is not currently legible with 4 spaces.

3

u/IDOLIKETURTLES Aug 03 '15

It doesn't help my understanding of wtf is going on by changing the indentation to two spaces ... It's still a mess. This pile of shit needs a complete refactoring.

1

u/d3vkit Aug 04 '15

I would suggest liberal use of the delete key.

2

u/IDOLIKETURTLES Aug 04 '15

ggdG should suffice.

0

u/[deleted] Aug 03 '15

[deleted]

3

u/barshat Aug 03 '15

Yes, Eclipse does have syntax highlighting and come cool "themes" that are supported by a plugin named Eclipse Color Theme. Link: http://eclipsecolorthemes.org/

10

u/G3KZOR Aug 03 '15

Of course there's a double ternary in the middle too.

6

u/bigpigfoot Aug 03 '15

if you nest it enough times, it resets the nest level back, making it really neat

5

u/RandomhouseMD Aug 03 '15

So, I worked at a place that brought me in to unfuck some of their code in preparation for them doing a site update. Their site (VB asp.net site ported from classic asp, with tools that were asp.net in C# along side it of course) had a handful of pages that were nested tables that were created by using office and "export to html". For the first and only time in my life, I had to deal with nested tables that actually indented so far that they wrapped to the next line in Visual Studio.

I was not unhappy to get to the end of that contract.

4

u/undergroundmonorail Aug 03 '15

One time a friend of mine was complaining about having to read code that looked like this to figure out how something worked. He said he would never trust the people who wrote it to code anything for him.

I later found out that he was looking at decompiled source code. I wonder why the style was garbage............

2

u/jarfil Aug 03 '15 edited Dec 01 '23

CENSORED

2

u/Daenyrig Aug 03 '15

Yo dawg. I heard you like nests. So I put a nest in your nest so you can read my nest in my nest in my nest in my nest in my nest in my ne- error occurred while generating redundant meme! Situation deemed too redundant to properly be meme'd. Please contact your local meme master for help.

2

u/nickadin Aug 03 '15

My condolences to the guy having to test this, covering all scenarios

2

u/breakybaby Aug 03 '15

i love how you can see 4k lines on the left .. :D

1

u/Jonno_FTW Aug 03 '15

1

u/[deleted] Aug 05 '15

>ProjectEulerJava

>Python

I feel cheated, and then disappointed you did not abstract this into beauty. :/

1

u/Jonno_FTW Aug 05 '15

Well originally all my attempts were in Haskell.

1

u/[deleted] Aug 05 '15

Coincidentally enough your code prompted me to try writing it in Haskell. I'll have to finish it another time though because I misinterpreted the problem (as usual with Project Euler, they should really stop wording their problems so terribly) and got frustrated. :P

Did you ever finish it?

1

u/Jonno_FTW Aug 05 '15

You can see my Haskell attempts in the repo (validity not guaranteed).

1

u/SideburnsOfDoom Aug 03 '15 edited Aug 03 '15

I don't know what hurts the most, the indented ifs & callbacks, or the fact that it's on line 4500 of one file.

No wait ... the ifs & callbacks are worse.

1

u/nolvorite Aug 04 '15 edited Aug 04 '15

Recursive functions don't real apparently

1

u/kerlick Aug 19 '15

MONSTER!

0

u/[deleted] Aug 03 '15

[deleted]

1

u/MaxNanasy Aug 03 '15

What's wrong with directly referencing undefined? (This is JS, right?)