18
Looking back at my first Python project from 2018, I was doing it all wrong
I found an old folder on my laptop last week, full of my first attempts at coding. I opened a file called 'my_program.py' and it was just one huge block of code, over 200 lines long, with no breaks. I remember thinking then that if it ran, it was good enough. What tipped me off was trying to add a simple feature to it yesterday and having no clue where to start, because nothing had a clear job. I spent more time figuring out my own mess than writing new code. It hit me that I never learned about breaking things into functions, I just copied big chunks from online forums. Now I'm going back to the start with a free course that focuses on clean code structure, not just making things work. Has anyone else had to unlearn a messy habit they picked up when they were just starting?
4 comments
Log in to join the discussion
Log In4 Comments
sean_green442mo ago
Totally feel that, my first scripts were the same giant mess. What helped me was forcing myself to write a one line comment at the top of every function explaining what it does before I even wrote the code. It made me stop and actually plan what each part should do. I also started using a linter that yelled at me about style, which was annoying but taught me a lot. Now breaking things into small pieces feels natural, but it took a lot of practice to get there.
1
susan_adams16d ago
Yeah writing a comment before coding forces you to actually think it through.
2