Skip to content

Comment on Ask HN: Examples of bad open-source code to learn what to avoid?

Comments

Here you go https://github.com/progwml6/Natura/blob/1.7.10/src/main/java...

Tip: If you ever end up in a situation where you have to copy-paste code with minor changes then there is something that you are doing wrong. In this case using arrays and loops would be a much better solution.

That looks nasty, but surprisingly hard to fix with loops because everything is of different types. If I were fixing it I'd look to some kind of code generation solution, even if just a hacky python script parsing a CSV.

(addShapedRecipe is just begging to have ASCII art as its canonical form)

Most of them are of the types button and item though.

But: avoid premature optimisation, it could lead to overly complex abstractions.

Simple, clear structures with little repetition are ideal.

Copy pasted data is painful to work with but still relatively easy to maintain and fix.

Overly complex and unintuitive abstractions are the most difficult to maintain and improve.

But it's very repetitive code and uses identifiers like "var3" and "var4".

The function addShapedRecipeFirst (List recipeList, ItemStack itemstack, Object... objArray) is really doing a number on me... gonna be fun not touching that code for a few months and when you come back you don't even know what the heck you are doing

I've never seen so many typographic rivers in source code before. Almost reminds me of a cross-eyed holograph.

Good god, my eyes, they burn.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.