Hey everyone! I've just started the 2025 CS50x course and it's been a lot of fun so far. I'm wrapping up week 2 and just tackled the encryption by substitution project. However, I can't help but notice that my code looks a bit like spaghetti—it works, but the structure is confusing with certain blocks placed all over the place, and my functions sometimes do too little or too much. Given that I'm still learning, should I really worry about the cleanliness and organization of my code, or is it more important to focus on just getting things to work right now? I feel like coding habits formed early can stick, so I wonder if I should be starting off on the right foot. Also, if I do need to focus on this, any recommendations for resources on coding conventions?
4 Answers
You definitely want to keep an eye on the cleanliness of your code. As you learn, it becomes important to recognize when things are getting messy and take the time to tidy them up. A fun challenge is to figure out how to reduce the number of lines of your code while still keeping it readable!
The idea of having perfectly structured code from the get-go can be a bit of a myth. It’s totally okay to get things working first and then plan to do some refactoring later. Just try to recognize when your code starts to get messy and plan to revisit it, but don’t feel pressured to get everything perfect right now. Take the time to experiment and learn, because that’s what’s most important at this stage!
No worries! As long as you understand your code well enough, you can clean it up a bit for your own sake and you'll be fine. There's no need to overthink it at this point.
Honestly, at this stage, don't sweat it too much. Just focus on getting your code to work well. Once you've got that down, you can go back and refactor it later to improve the structure. It's a normal part of the learning process!
Totally agree! Trying to enforce best practices so early can just stress you out. Focus on learning and experimenting for now.