7
My mentor told me my code looked like 'angry spaghetti' and I finally learned how to use functions properly
After 6 months of writing 200-line scripts with no structure he sat me down and showed me that one function per task makes debugging actually possible, has anyone else had someone call their code something weird that completely changed their approach?
3 comments
Log in to join the discussion
Log In3 Comments
iris_mason881mo ago
Oh come on, that's terrible advice. Shoving everything into one big script forces you to actually understand the whole flow instead of hiding behind a bunch of tiny functions that each do one thing. I've seen people split code into 20 little functions and then spend twice as long trying to trace which one is broken. Keeping it messy and linear means you can scan from top to bottom and spot the problem in seconds.
5
victor_adams951mo ago
Right, tiny functions make debugging a nightmare when you're hopping all over the file.
2
the_michael1mo ago
My old mechanic used the same logic when he taught me to fix my car - one system at a time instead of trying to diagnose everything by just staring at the whole engine bay. It's funny how we resist breaking things down until someone calls us out on the spaghetti.
1