My number one piece of advice for someone entering college and studying computer science is the following sentence: Write pseudocode before writing your actual code. If you follow this piece of advice, you will literally save yourself hundreds of hours over the next 4 years of your life.
Pseudocode is a plain language description of an algorithm that will help you implement the code in whatever computer language you choose to use (Python, Java, C++, etc.). There isn’t a “correct” way to do it, but simply taking the time to write out exactly what you are trying to do will save you lots of time down the road. An example of pseudocode for making a PB+J sandwich is:
// Go into kitchen
// Open pantry
// Grab peanut butter, jelly, and bread from pantry
// Open utensil drawer
// Grab a knife
// remove bread from bag
// Open peanut butter
// Spread peanut butter on 1 piece of bread using the knife
// Open jelly container
// Spread jelly on other piece of bread using knife
// Put 2 pieces of bread together to form sandwich
If you’re like me, then you’re probably thinking that pseudocode is dumb and a waste of time because you shouldn’t have to take the time to sit down and write instructions for yourself when you can just go into the kitchen and make a sandwich. However, as the complexity of a given task increases, you may need to really sit down and think about how exactly you want execute a given task. For example, imagine if you don’t have any jelly. What if you started making your sandwich and spread all the peanut butter on some bread and then realize you need to run to the store to buy some jelly, so you leave with some peanut butter and bread on the kitchen counter and while you’re gone, your dog eats all your peanut butter and bread. You’ll probably wish you spent time to think about your entire process before beginning. Ok, I’m going to shut up about sandwiches for now.
By writing pseudocode, you can increase your chances of avoiding two time-sucking issues. The first of which is debugging. If you have an easily readable roadmap, then when your code inevitably does not work, you can go back and retrace your steps from start to finish. It will be easier to distinguish between syntactical errors (misspelling of a variable) and errors in your logic (you put the pieces of bread together before spreading the jelly).
The second issue you’ll avoid is a “wrong turn” error. This is when you are spending hours building something and you get to a point where you realize you have been going the wrong direction the entire time. If you had taken the extra time to map out your entire process using pseudocode, then you would’ve saved yourself the hassle of beating your head against a problem that you shouldn’t have even been trying to solve in the first place.
I have made the error of just rushing into a project without thinking about the bigger picture too many times to count. If I had slowed myself down at the beginning and taken the time to write pseudocode beforehand, then I would’ve gotten a lot more sleep in college.