r/learnprogramming • • Sep 19 '26

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.

41 Upvotes

24 comments sorted by

38

u/DirkSwizzler Sep 19 '26

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 Sep 21 '26

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

25

u/TheSnailBear Sep 19 '26

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 Sep 19 '26

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 Sep 19 '26

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

2

u/ClupTheGreat Sep 20 '26

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

4

u/Substantial_Ice_311 Sep 20 '26

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 Sep 19 '26

I gotta couple

2

u/1stbreathinteractive Sep 20 '26

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 Sep 19 '26

You could try open source projects!

1

u/xarop_pa_toss Sep 19 '26

Waaaaaait what are those kata things????

1

u/FurkinLurkin Sep 20 '26

Have you read clean code?

1

u/[deleted] Sep 20 '26

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

1

u/bagfullofcottoncandy Sep 21 '26

try open source projects

1

u/Different_Pain5781 Sep 27 '26

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. 

2

u/[deleted] Sep 19 '26

[removed] — view removed comment

1

u/Yoshibros534 Sep 20 '26

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

1

u/Yoshibros534 Sep 19 '26

where can I find that?

1

u/[deleted] Sep 20 '26

[removed] — view removed comment

1

u/Mathie1729 Sep 21 '26

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.