Live data from Hacker News

TerrariaClone – An incomprehensible hellscape of spaghetti code

github.com

221–230 of 289 posts

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#221
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.

Totally agree, and as for ownership imho it all depends what level of complexity we are a taking about, if it's some web bs (no offense) it's one thing, if we talking about some parallel gpu FEM physics solver trust me there will be ownership and I think it's a good thing...

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#222
post #108

Earlier quoted context omitted.

As I had to work more with teams and then supervising teams I changed the abstractions I value from when I was programming solo: Now I care less about my project's function than the structure of the team. There is a saying that any complex project will end up mimicking the communication structure of your organization. I must confess I thought it was silly until I realized it happened to us. I now favor code that has…

> allows programmers, these very territorial beasts, to have their own little realms they control My 25 years of programming experience says otherwise. The only place where this works is with good(ish) programmers who are assholes and must have their huge, fragile egos stroked or they'll throw a diva fit. I don't hire or work with those people anymore. Neither should you. Joint code ownership produces better code bec…

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, people lose autonomy and can't fully act on their own vision.

The alternative is to think up new architectures and team structures that allow more people more freedom to work.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#223
post #190

Earlier quoted context omitted.

I believe so too, but it's not even that much a function of team structure. A proper design will have lots of places that are mostly self-contained at various levels of abstraction - more than people you have in your team. I believe work should be distributed among those boundaries, because it lets people agree on the interfaces and work mostly in isolation. Also, most of the time, small self-contained units of code…

Re: 0 sometimes I wish I could just be paid to read and understand code.

Are you being paid per written line of code or something? I just can't think of a reason to believe as a programmer that your job responsibilities don't include reading and understanding code.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#224

Earlier quoted context omitted.

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...

You used to be able to decompile Terraria into perfectly readable code, since its c# and they didnt use an obfuscator. The code base was atrocious, but it is impressive that they got something working, and pretty fun, together as quickly as they did. These days there are a fair amount of production Unity games out that you can extract full sources for.. Can make for a fun read sometimes.

If I remember correctly, the author of Terraria was also just learning C# as he went on with this project.

It's a huge success story in my book.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#225
post #217

Earlier quoted context omitted.

> There is a saying that any complex project will end up mimicking the communication structure of your organization. I must confess I thought it was silly until I realized it happened to us. Is this necessarily a bad thing? I know this quote and it always made a lot of sense for me. But I never understood where exactly is the problem, and why one should go to great lengths to avoid this. Moreover, in this concrete ex…

They aren't saying it's bad. They're saying it happens. And that you need to be aware of that if you want your code to end up maintainable.

What does it mean to "be aware" of this? What should one do differently from one would otherwise do?

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#226
post #61

Earlier quoted context omitted.

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

Wouldn’t “else if {“ and “else { if” compile to identical bytecode?

It does and at least the current dotPeek 2017.2.2 decompiles it to else if and does, other than I thought, not allow to customize it.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#227

Maybe the introductory text primed me to expect much worse, but I actually found the code quite readable although definitely underabstracted. I was expecting the opposite, the sort of code I usually see from beginning Java programmers: classes and methods everywhere, but almost no real work. A long time ago, I (briefly) worked with Enterprise Java. The things I saw were far worse than this. 100+ deep callstacks[1]. D…

I love me some good abstractions. But abstractions don't automatically make code more readable or efficient. They're overhead that shows their worth through volume and use. I follow the rule that you never abstract based on one instance, or even two. Show me three places you know this will be used, then if we know how it's going to be used we can figure out the best way to generalize that functionality.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#228
post #225

Earlier quoted context omitted.

They aren't saying it's bad. They're saying it happens. And that you need to be aware of that if you want your code to end up maintainable.

What does it mean to "be aware" of this? What should one do differently from one would otherwise do?

It means that poor communication among team members will lead to poor code, and likely a poor or late product.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#229

Earlier quoted context omitted.

> allows programmers, these very territorial beasts, to have their own little realms they control My 25 years of programming experience says otherwise. The only place where this works is with good(ish) programmers who are assholes and must have their huge, fragile egos stroked or they'll throw a diva fit. I don't hire or work with those people anymore. Neither should you. Joint code ownership produces better code bec…

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…

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 choices for the benefit of the wider team results in much better code.

Re: TerrariaClone – An incomprehensible hellscape of spaghetti code

#230
post #227

Maybe the introductory text primed me to expect much worse, but I actually found the code quite readable although definitely underabstracted. I was expecting the opposite, the sort of code I usually see from beginning Java programmers: classes and methods everywhere, but almost no real work. A long time ago, I (briefly) worked with Enterprise Java. The things I saw were far worse than this. 100+ deep callstacks[1]. D…

I love me some good abstractions. But abstractions don't automatically make code more readable or efficient. They're overhead that shows their worth through volume and use. I follow the rule that you never abstract based on one instance, or even two. Show me three places you know this will be used, then if we know how it's going to be used we can figure out the best way to generalize that functionality.

The worst is when the abstraction is designed prematurely for some limited use case, and then when you want to expand on it, you're stuck in some rigid format and have to either hack at it or rebuild the entire abstraction.

This is a major reason why I no longer like OOP (I used to be religiously wed to it). Lightweight functions in modules, with structures that basically just hold data can be cleaner and far more flexible than a big object.

Post reply on HN