Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

261–270 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#261

Earlier quoted context omitted.

There's a tension between "everyone writes some of it" and individuals having autonomy to focus and make decisions. If everybody has autonomy in a shared codebase, you end up with a heterogeneous spaghetti of unrelated design decisions and styles overlapping everywhere. To solve this, you normally end up with a hierarchy of authority, where most people have to have their work vetted by seniors. In this process, peopl…

Strict hierarchies suck because if you're a leaf in the hierarchy, it's very difficult to collaborate or work with other leafs that are not in your same sub-branch. A flat fully connected hierarchy is better for small groups, but it doesn't scale well as the number of lines of communications is proportional to the square of the number of people.

no it's not, broadcasting is linear, alas its not strictly parallel.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#263
post #78

Earlier quoted context omitted.

Premature abstraction is generally worse than immature abstraction. Write the most straightforward thing you can, and wait for that feeling that it won't work out. Then, ignore that feeling until you get proof. If you've kept your code simple and clean reacting to a lack of abstraction is relatively easy, at least compared to what digging yourself out of the wrong abstraction is like.

This is so true. Even a horrible God class with 6500 lines of code is still many times better than an overdesigned framework with 100 classes of 65 lines each.

hard to tell what you think would be the significant difference between horrible and overdesigned.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#264

I did a 3 month contract working on porting Terraria (the actual game) from XNA to Unity and updating things like UI from sprite batching etc. Coincidentally and fwiw, the actual source code to Terraria was also a hellscape of spaghetti code.

> porting Terraria (the actual game) from XNA to Unity Can you talk about this? What was involved? Why do it? Major roadblocks? Do you feel it was it worth it?

You can hire cheaper ready-made Unity devs afterwards. There is even a certification now.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#265

The best thing about this is the open issue claiming it's "Too much like the real Terraria source code." [1] :) This bring back a lot of memories. Way, way back in the day i wrote a clone of Battle City [2] in XNA with a half-decent AI. I had intentions to learn and use some OOP patterns. I ended up with a handful of monstrous classes and generally a clusterfuck of spaghetti code. But... i learned a lot about AI and…

Holy shit. Be sure to read the issue. It turns out it's not really a joke - someone in the know points out that Terraria's code is basically the same quality, if not worse...

Bloody Hell, that code “snippet” just keeps on giving. Makes me feel a bit better about that tightly coupled ball of mud I barfed out last week. Lol.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#266
post #163

Earlier quoted context omitted.

Maybe those are stubs the author intended to do something else with later?

Original author here. I can confirm that the actual reason is that at the time I thought typing "print" instead of "System.out.println" was a great idea.

It IS a great idea!

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#267
post #237

Earlier quoted context omitted.

If everybody has autonomy in a shared codebase, you end up with a heterogeneous spaghetti of unrelated design decisions and styles overlapping everywhere. Being free to do things your own way often means choosing not to do something if it's going to negatively impact other people. Once you realise that you need to think about the way your decisions impact other people you quickly realise that compromising on your cho…

The trouble is that in closely cooperating teams where I worked, people who did what you suggest ended up in submissive position against people who just do their thing ignoring others. If I proactive think about others and you don't, you get to work however you like it oftentimes making my work more difficult - while I am more restricted and have harder time to make my ideas reality.

> people who just do their thing ignoring others

in a professional context requiring collaboration, that's an asshole move, and people who do that sort of thing on a regular basis should be reprimanded.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#269
post #144

Earlier quoted context omitted.

Was the comment of that commit 'initial commit'? :)

Not GP but probably: “ Here be dragons ”

I actually did that once.

It was a wordpress site for a company written by some 16 year old intern. Terribly fun. No version management. The main folder had multiple older copies of itself in seemingly random subfolders. It went deep. The CSS was stored partially in CSS files, of which there were 20 (!) loaded from the theme folder, partially in one of the 40+ plugins used (not an exageration). But there was also plenty of CSS in the templates, the database and seemingly random third party servers. The favicon was 20MB large. It used like 4 plugins for “custom fields” all of which had infected large swathes of the database, and all of which did... something. Much like the root folder had nested copies of itself there was something similar going on in there... I simply didn’t bother by the time I understood what the hell was going on. The templates were basically this premium theme of “customized” php, the fun part was that in some page templates it basically rendered a bunch of different pages inside the template (the guy apparently didn’t understand the concept of closing tags, yet somehow made it work. It was incomprehensible.) and then used custom css to hide the pages that shouldn’t be visible. Basically the entire thing was some satanic equillibrium of bugs cancelling eachother out.

It was a work of art.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#270
post #78

This makes me miss my early days of programming, where no code was too verbose or horrible to stop me from progressing towards my goal, no matter how misguided I was. Nowadays I'm distracted by the first hint that there might be some better way, and all progress stops. I think I'm just beginning to recognize this, and maybe one of these years I'll learn to recognize when the right abstraction is really important and…

Premature abstraction is generally worse than immature abstraction. Write the most straightforward thing you can, and wait for that feeling that it won't work out. Then, ignore that feeling until you get proof. If you've kept your code simple and clean reacting to a lack of abstraction is relatively easy, at least compared to what digging yourself out of the wrong abstraction is like.

I feel James Coplien's advice on the question is interesting: https://www.youtube.com/watch?v=KtHQGs3zFAM&t=500

TLDW: "refactoring your way out" from a simple but too short-sighted design might take a ridiculous amount of work, compared what would have been necessary if you knew what a "correct" design for this problem was.

Post reply on HN