Live data from Hacker News

Anyone who looks at this code instantly becomes insane

github.com

71–80 of 81 posts

Re: Anyone who looks at this code instantly becomes insane

#71
post #49

Earlier quoted context omitted.

I'm a second-year CS student that is still learning in this realm. Is there a general way that most developers would rewrite lines 5261-5284? My assumption is I would look to find some rules I can apply to simplify the code but I'm also aware a CS course is a bit of a bubble and what I've learnt so far might not be the way things are handled in industry. For example, line 5284 has a 8 inequality operators checking ev…

As mindfulgeek mentions, doing some sort of extract method refactor to slop a name onto it can be a good first step. Then do some sleuthing thru other number name pairings, inserting names in place of the numbers, until you have a solid grasp of what the names should actually be. Feathers in Working Effectively With Legacy Code brings up a concept called seams... u can insert a seam to map to objects and then do obje…

https://github.com/polytomous/TerrariaClone/issues/6 gives an example of how i work thru this sort of question, but its also spoiler laden so view at your own risk.

Re: Anyone who looks at this code instantly becomes insane

#72
I have a project from last year where I made my own little pokemon game using processingjs. I thought I had some decent knowledge of developing but the code consists of a file with 1900+ lines of code. It's terrible.. Also because I had barely any knowledge of how I should structure code.

Re: Anyone who looks at this code instantly becomes insane

#73
post #41

> it does not encourage meaningful / non-ableist dialog with the work Is it really ableist to think that sanity is objectively better than insanity? > ins*ne This is peak wokeness. We can’t even spell out the word “insane” for fear of offending someone.

Ok, but please don't cherry-pick provocations from other places and bring them in here to get upset about. It's agitating, but not interesting.

Re: Anyone who looks at this code instantly becomes insane

#74

I wouldn’t ever want to work with this code, but there’s a level of persistence here that I kind of respect. Sure, the code sucks, but I can’t help but feel like I couldn’t have written this even if I wanted to. There’s usually a point when I’m too deep in a nested conditional to remember all the variables, and that’s usually before 23 tabs in.

This was written by a 14 year old kid. If anything it is an impressive testament of precocity and ingenuity.

Re: Anyone who looks at this code instantly becomes insane

#75
post #49

Earlier quoted context omitted.

I'm a second-year CS student that is still learning in this realm. Is there a general way that most developers would rewrite lines 5261-5284? My assumption is I would look to find some rules I can apply to simplify the code but I'm also aware a CS course is a bit of a bubble and what I've learnt so far might not be the way things are handled in industry. For example, line 5284 has a 8 inequality operators checking ev…

> A second question: Why is there no comments? Is this common? Man I remember being this naive once :(

My first major project (at an internship) had all the comments on every file (even getters / setters, and it even had getters/setters because someone told me to). Interestingly enough it was a project that had to read static analysis tools' output and combine it into a single report / webapp, so I was very aware of all the output that was reported and all the niggly little things that these tools (think PMD, CPD, FindBugs, etc) pointed out. Including how a getter wasn't commented.

Re: Anyone who looks at this code instantly becomes insane

#76

> The TerrariaClone.init() method, which is over 1,300 lines long, actually grew so large that the Java compiler started running out of memory trying to compile it! The solution? Copy half of the init() code into a new method, called codeTooLarge(), and call that from init() I found this in the readme, hilarious (not in a mean way).

Modern problems require modern solutions!

Didn't Facebook and other major app developers run into issues with having too many classes for Android's JVM?

Re: Anyone who looks at this code instantly becomes insane

#77

> The TerrariaClone.init() method, which is over 1,300 lines long, actually grew so large that the Java compiler started running out of memory trying to compile it! The solution? Copy half of the init() code into a new method, called codeTooLarge(), and call that from init() I found this in the readme, hilarious (not in a mean way).

Modern problems require modern solutions! Didn't Facebook and other major app developers run into issues with having too many classes for Android's JVM?

Oh we had the same kind of issue moving a spring project into lambdas ...

Don't do that kids

Re: Anyone who looks at this code instantly becomes insane

#78
I cloned the repo, wrapped it in Maven and sent it to SonarQube.

- 9.5k lines of code

- 333 bugs

- 2 vulnerabilities

- 6 security hotspots

- 56 days of technical debt

- 2172 code smells

- 0.0% coverage

- 21.5% duplications

- 117 duplicated blocks

I might be masochistic enough to try to fix these issues with a merge request.

Re: Anyone who looks at this code instantly becomes insane

#80
post #59

About 12 years ago I was working at a company in which a developer had recently left, and left behind some code that had a bug in it that needed fixing, the code was processing some XML and I knew a lot about XML so I was called over to look at this code. The code was actually very simple, it consisted of for loops over a bunch of element nodes in which child nodes had to be compared with child nodes in other element…

Reminded of a time I took the code of our Data Scientists (2 physicists that "coded". They decided to make their own ORM in Ruby (called "Mondongo") instead of using one available. No wonder, the code was a real mess... For example, they needed to get a numeric value from a dropdown box that got several text options. The way they did it was: fieldVal = textField.gsub('text string 1',0).gsub('another string 2',1).gsub…

I have actually done a similar WTF myself when I had been programming professionally for about a year, I had to do a validation on SOAP requests for some EU project in ASP in 1999-2000 (thankfully only one of the acronyms in that statement are still relevant) and the parameters for doing it had changed a couple days before.

There was a requirement that we had to deliver all validation code in VBScript that would run in the ASP but also should handle possible future changes to the request, and I had examples of all valid possible requests (which as I said had just been changed a couple days before), so I wrote an XSLT that went over all the XML templates and generated a bunch of VBScript if statements and for loops for each possible valid request and if it didn't find it returned an error message that it was invalid.

So anyway based on the theory that I can understand any stupid coding wtf I myself have done - if the wtf code is generated by some other better code I understand why the code is so awful, but if it is handwritten I still don't understand. And my guy handwrote his code. I'm guessing yours too. crazy.

Post reply on HN