My First Week of Learning Code

Some tips to start out coding

My First Week of Learning Code

I started learning to code again last week. My last stint with CS50 was in 2017. I've already progressed further in the course than my previous record. The biggest difference so far is my attitude to undertake this journey. I'm setting out to enjoy this learning experience to complement my internet entrepreneurship journey. After writing code for hours every day and still have mountains to climb, I have these tips for those just starting out.

Write Code by Hand First

I spent time before creating the program file writing code down by hand first. What you're thinking at this level doesn't translate into code easily. That's all programming is, human telling computers what to do. So what does the program needs to do? Write down in real code on paper or notes app whatever. You can also write in pseudo code and Google how to actually carry out that function later.

Chances are your first design on paper wouldn't work out but that's ok. You can work through your problems by hand again. The first programmer did her work by hand too! Try going through it line by line. What does the program do here? What needs to be checked out? What needs to be true and what needs to be false?

Don't be Afraid to Start Over

You'll need to write loops and conditions. They're the foundation of programming. When the problem doesn't do what you want it to do (and this will be often), it can be tempting to add ever more lines to the overstrained loops. If looping twice doesn't solve this, then loop once more!

A fresh start is always an option, just delete everything and start over! You don't waste anything throwing out code that's not working. Maybe this problem has a better solution by flipping everything the over way around. Weirdly the final solution is almost always simpler looking than what we set out to create in the first place.

Google Everything

The best programmers in the world Google everything all the time. It's part of the setup really. So let's learn from the best! The course you're doing won't explain everything the way that suits you. It can be a great help to see the concepts explained in different sources.

For me seeing examples of functions working really helped me to understand them better (OHH so they output 0 and !=0). A site packed with the best examples I found so far is Programiz.

Write Pretty Code Please

It might be tempting to keep your spaghetti code. After all, you and the computer understands your code. But you need to work with other humans down the line right? Even going back to look at your code later you don't even know where is where!

Go through coding style guides and imitate examples of coding conventions. Thankfully, CS50 comes with style checker too so I get to see what I've been doing wrong and adjust. This is training the muscle memory to write it well the first time.

Have Fun!

The most important principle on this list! You'll be spending hundreds and thousands of hours programming. It'll be a disservice to yourself if you don't find it fun. Of course you'll bump into very frustrating problems and struggle to learn many concepts. In that case it's perfect to take a break! You'll come back with fresher mind and maybe even breeze through previously difficult problem! Don't just learn things because the course says so, find programming things you're interested in and learn that too! Now I'm off to write more code.