4
My first project went from 500 lines of spaghetti to 100 lines of clean code in a week.
I built a simple weather app last month. The first version worked, but it was a mess. Every function did three things at once. I had variables named 'stuff' and 'thing'. Then I watched a 20 minute video on YouTube about 'single responsibility principle'. It clicked. I spent the next week rewriting. Broke everything into tiny functions with clear names. Used comments to explain the 'why', not the 'what'. The app does the exact same thing, but now I can actually read it. Feels like a different program. Has anyone else had a moment where a simple concept just cleaned up their entire approach?
3 comments
Log in to join the discussion
Log In3 Comments
faithg261mo ago
Oh man, the temp variable struggle is SO real. I still catch myself doing it when I'm in a hurry, but I force a pause now. What really helped me was writing the function name first before I write any logic. Like if I can't name the function in 5 words or less, I probably don't understand what it's actually supposed to do yet. I also started leaving myself little notes in comments about why I chose a certain approach, not just what the code does. Future me always thanks past me for that. And yeah, breaking things into tiny functions feels weird at first like am I overdoing this? But then you fix one bug and realize you only had to change 3 lines instead of rewriting half the file. That's when it all clicks.
7
lee.diana3mo ago
My early code was just a bunch of "temp" variables.
4
miller.jason3mo ago
Used to do the same thing, thought it was fine. Then I had to fix a bug in my own code six months later and spent an hour just figuring out what "temp7" was supposed to hold. Now I write names so clear my future self won't hate me. It's a game changer for actually understanding your own logic.
2