Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

61–70 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#61
post #23

Earlier quoted context omitted.

Decompiling .NET or Java binaries usually yields code very close if not identical to the original source code, at least unless an obfuscator was used but that seems not to be the case here. Chances are very good the original source code looks almost exactly like that code, maybe with some additional comments.

In this case, it's just that the decompiler didn't think of "else if" as a single control flow construct/keyword in the way that the original programmers did. What was no doubt written like this: if(a Decompiled into this: if(a

I will try this tomorrow, I am pretty sure dotPeek can recognize and output else if. Might be a coding style option though.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#62

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…

watching the creator of The Witness do some live stream coding made me realize this too. he just typed the convenient thing he needed at each moment and didn't try to abstract away the mess. just forged ahead.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#63
post #25

I think true spaghetti code requires teamwork. I mean that seriously. You need at least 3 people all with different incomplete and incorrect mental models trying to modify the same codebase at the same time.

I disagree. I inherited an app that I'm maintaining that was written by one person over ~12 years. When requirements were added, he just cloned the app and started making the changes so the new app would meet the requirements. Repeat 2 more times, and you get to now, where there are 4 similar but not identical versions of the same code base, with inconsistently applied fixes to various bugs. All 4 still need to work for the organization to function.

It's old school PHP, with sql queries mixed in with markup mixed in with php business logic - if that's not spaghetti code, I don't know what is.

(I'm replacing it, but it's a very slow process).

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#64

This reminds me of the C# source code for DRAGON. Its code was actually much worse, because the creator wasn't aware of things like loops or method definitions (the main game loop and class appear to have been generated by a framework). The C# code is here, and it works well enough that you can buy it on Steam, apparently: https://gist.githubusercontent.com/alessonforposterity/832da...

The ability to buy something on Steam is sadly no longer a guarantee that it works.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#65

This reminds me of the C# source code for DRAGON. Its code was actually much worse, because the creator wasn't aware of things like loops or method definitions (the main game loop and class appear to have been generated by a framework). The C# code is here, and it works well enough that you can buy it on Steam, apparently: https://gist.githubusercontent.com/alessonforposterity/832da...

I'm a bit reminded of the central GAME.C file from the original Duke3D source code: https://github.com/videogamepreservation/dukenukem3d/blob/ma...

It's almost 10k lines of nested if statements, lots of magic values and so on. Still one of the most enjoyable games of its time :-)

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#66
post #44
post #9

I love DoubleContainer: https://github.com/raxod502/TerrariaClone/blob/master/src/Do... which is fortunately only used in a comment here: https://github.com/raxod502/TerrariaClone/blob/9ea04b15add48...

I really like this method: https://github.com/raxod502/TerrariaClone/blob/fd1ff8b8b0e78...

That is probably (x + 1) % 10 assuming x is non-negative. That kind of code is responsible for quite a bit of the verbosity, the author was obviously not aware of many of the little tricks usually used in this kind of code.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#67
post #44
post #9

I love DoubleContainer: https://github.com/raxod502/TerrariaClone/blob/master/src/Do... which is fortunately only used in a comment here: https://github.com/raxod502/TerrariaClone/blob/9ea04b15add48...

I really like this method: https://github.com/raxod502/TerrariaClone/blob/fd1ff8b8b0e78...

Well, it's faster than %, but I bet it's premature.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#69
post #63
post #25

I think true spaghetti code requires teamwork. I mean that seriously. You need at least 3 people all with different incomplete and incorrect mental models trying to modify the same codebase at the same time.

I disagree. I inherited an app that I'm maintaining that was written by one person over ~12 years. When requirements were added, he just cloned the app and started making the changes so the new app would meet the requirements. Repeat 2 more times, and you get to now, where there are 4 similar but not identical versions of the same code base, with inconsistently applied fixes to various bugs. All 4 still need to work…

My inherited spaghetti codebase took only 24 months for my predecessor to build. I was told: "don't worry, it's in SVN and all of the important switches are clearly laid out at the top."

Well, it was in an SVN repo... with a single commit.

It did have all the important switches at the top, none of them but the ones that were set actually worked.

Man, I "miss" that job.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#70
post #64

This reminds me of the C# source code for DRAGON. Its code was actually much worse, because the creator wasn't aware of things like loops or method definitions (the main game loop and class appear to have been generated by a framework). The C# code is here, and it works well enough that you can buy it on Steam, apparently: https://gist.githubusercontent.com/alessonforposterity/832da...

The ability to buy something on Steam is sadly no longer a guarantee that it works.

I played it. it worked.
Post reply on HN