Skip to Content

Basic Programming Ideas

1. ABC, always be compiling

Don’t write lots of code and then try to compile and run it. Write small amounts of code, compile and run and test them, and only then write more code. Program in small baby steps always!

2. Be OCD about code indentation (and other style)

Do NOT let your code get sloppy, and most especially do not let it be wrongly indented. You will never be able to figure out wrongly indented code by looking at it. If you are using a code-smart editor or IDE, learn to use its auto-reindent features.

3. When in doubt, print it out

Don’t just stare at your code when debugging, add print statements and print out your variables so that you can see what is happening. Later on, learn to use a debugger, but add print statements is an easy and awesome way to learn to debug.

4. Comment out code before deleting it

If you need to remove some code that you have while trying to get different things working, comment it out rather than deleting it. One, you will still be able to see it and what it was trying to do, and two, you might need it again.

5. Don’t be afraid to create more variables

The answer isn’t always to figure out how to use your existing variables better – you simply may need to be saving more data.

6. Don’t just blindly use code from the Internet or an AI

Many times students cut and paste code right into their program that is “supposed to” do some task they need done. But no effort is made to figure out how this code will work with their existing code, and to understand what it is doing. Don’t do this!