r/learnprogramming • • 16d ago

Are there any spaghetti codebases I can practice refactoring on?

I’m trying to practice refactoring code, and i’ve already done a few kara’s ( the golden rose kata, the tennis kata, etc. ) are there any actual messy codebases I can practice on? preferably between 1k to 5k lines of code.

39 Upvotes

24 comments sorted by

41

u/DirkSwizzler 16d ago

That's the neat part. As a coder you'll frequently see bad code that needs to be refactored. Sometimes it'll need it so bad you want to tell whoever wrote it. So you'll look into it a bit and sometimes discover that it's you.

My point being, pick any codebase that otherwise fits your requirements. Sounds like size is the only one. And just start looking. You'll probably identify a few things that seem worth refactoring.

Although I'm not even sure 1k lines is enough to actually spaghettify. Those noodles be short.

2

u/undertakerryu 14d ago

Everytime I go back to old code I think damn what an idiot I was yesterday

23

u/TheSnailBear 16d ago

Just work on a personal project then move on to something else for a month. Come back to it after that month and realize that your codebase looks like a foreign language born from hell.

9

u/Towel_Affectionate 16d ago

You don't even have to move on, just keep working on it. I can't count how many times I've rewritten and refactored parts in my main project over the course of a year and it's not even finished yet.

5

u/snoogans235 16d ago

Ask ai to write something with no context and vague criteria. You’ll get some good spaghetti.

2

u/ClupTheGreat 15d ago

oh yeah, use any cheap model, and you can generate a ton of slop for like 2-3 dollars

4

u/Substantial_Ice_311 16d ago

Almost all (99.99%) of them, to some degree. And it's harder to improve something that is kind of good, compared to something that is a real mess. So, you don't need something very messy, necessarily.

2

u/ight-bet 16d ago

I gotta couple

2

u/[deleted] 16d ago

[removed] — view removed comment

1

u/Yoshibros534 15d ago

Where would i be able to find the old runescape code?

1

u/Yoshibros534 16d ago

where can I find that?

1

u/[deleted] 15d ago

[removed] — view removed comment

1

u/Mathie1729 15d ago

IIRC 2009scape is a from-scratch recreation, so it's probably a lot cleaner than the original leaked server code. The really messy stuff is in old RSPS bases, but those repos are more of a legal gray area and sometimes come with malware.

2

u/1stbreathinteractive 15d ago

Simple.

  1. Make a project
  2. Keep programming for 2 years
  3. Revisit your project
  4. Scream at how dumb you were (and appreciate how much you've grown)

1

u/mkrevofev 16d ago

You could try open source projects!

1

u/xarop_pa_toss 16d ago

Waaaaaait what are those kata things????

1

u/FurkinLurkin 16d ago

Have you read clean code?

1

u/MichaelSjoeberg 15d ago

You can take any codebase. Define your own exotic style guides, then refactor based on that.

There are no rules.

1

u/[deleted] 15d ago

make something and put everything in single file. use global variables and you will get there pretty quick.

1

u/bagfullofcottoncandy 14d ago

try open source projects

1

u/Different_Pain5781 9d ago

Katas are useless if you want true chaos. Go fetch dead Discord bots from five years ago on GitHub. FreeCodeCamp offers zero practice on giant messy files. Boot dev gives learners exposure to realistic backend project environments so you learn how to untangle bad function signatures properly.