O
24

My friend told me my code was 'spaghetti' and I finally get it

He looked at a Python script I wrote and said, 'You're putting everything in one big function, it's impossible to follow.' I broke it into three smaller functions with clear names, and now I can actually read it myself. Has anyone else had that 'aha' moment about organizing their code?
3 comments

Log in to join the discussion

Log In
3 Comments
sethk50
sethk501mo ago
Oh man, that first refactor is such a great feeling.
2
the_ben
the_ben1mo ago
That spaghetti code phase is real. I mean, I once wrote this whole data scraper as one massive loop with like five nested if statements. Took me an hour just to remember what the middle part was supposed to do. Breaking it out felt like cleaning a really messy room.
2
abbychen
abbychen9d ago
Also makes it way easier to write tests when you have small isolated pieces.
2