Six common mistakes beginner progammers can avoid

1. Solving all problems at once

You have so many great ideas on how to improve your program. But when you want to implement them nothing seems to work. You break your whole program and become frustrated. Out of five ideas you manage to get one to work  partly.

With all you have learned it’s tempting to be carried away by all the great possibilities. You want to make work everything at once and will most likely fail. Try to take one small step at a time. This is called baby steps and will help you focus. Test your program after every step. This way you will know exactly when, where and why you broke something.

Sometimes problems seem far too big and complicated. Try to divide the problem in smaller parts. Write them down on a sheet of paper and solve them one step at a time. Divide further when one step is still to complex to solve. The best part: This approach does not only work in programming but as well in many other situations!

2. Staring at code

There is this huge mess of code that you wrote just yesterday. And somehow it’s working  well, partly. But you can’t figure out this last bit. You know it should be working this way, but somehow… And then you start staring at your code. Minutes and hours pass, you change some lines here and there, continue staring but nothing works.

Here is some advice for novice programmers: Staring at code does not solve your problem. If five minutes of your full attention does not solve it, fifteen minutes will change nothing. Your brain will see the code that’s written but not the code that could solve your problem. Go away from your code. Grab something to eat or take a walk. Talk to other people  about your problem or about something unrelated. Our brain tends to solve problems in the background, when we sleep, eat or do something completely unrelated.

Designer novices are taught to scribble their ideas on a piece of paper before implementing their design. Do just that. Grab a piece of paper and write down some concepts you want to use and the steps you need complete. When you’re stuck scribble down your problem. Show it to other people so they can help you.

3. Not knowing what exactly you want to achieve

a figure with question marks Sometimes it’s great to experiment. Tweak some numbers here and some formulas there. It is a great way to learn. But sometimes you will get carried away. Don’t try to solve a hard problem or your homework just by experimenting. Write down what you want to achieve and which smaller steps you need to do. Think before you start writing code. When you feel like one problem follows the next look back at your objective.

Read the text of your exercises and homework carefully so you don’t miss some important information. More often than not there are hints hidden inside the text. Talk to your fellow students about how they understand the exercise.

4. Not reading error messages

This is something I learned while mentoring novice programmers. You don’t like to read error messages. They are complicated, full of stuff you don’t understand yet. And, well, you know what could have gone wrong just fine without them.

Don’t do that. Error messages can be a scary wall of red text. But in most cases they explain quite well, what just went wrong. Syntax error? You might have forgotten a semicolon or some brackets. A variable is not defined? Maybe you made a typo.

a warning signLearn how to read error messages. Try to remember the ones that you encounter very often and find out what kind of errors in your code triggered them. Ask someone when you don’t understand what they mean.

5. Feeling dumb

Programming can be intimidating and overwhelming. You were never good at math or when you were it somehow feels very different while coding. All these technical terms don’t make sense at all (at least most of the time) and your computer won’t  understand what you are asking for.

Most of use started this way and even “expert” programmers don’t know everything. They just know where to look stuff up they don’t understand. So find man pages, tutorials, forums and references where you can look up terms and concepts you don’t understand. Be curious. Ask questions. You don’t remember the difference between an integer and a float variable? Don’t be shy. Ask your teacher, tutor, fellow student or the Internet until you feel conformable enough to go on. There are really no dumb questions. Just be sure to think about what you want to ask before you ask. Explain which part you understand and which part you don’t. If you want to know more ask for learning resources like books and online courses.

The greatest way to not feel dumb is to teach other people. Help your fellow students with tiny problems you already solved. Try to figure out solutions together. Talk about problems you had and still have  you will be surprised how similar your problems are.

You hate math, formulas and functions? Math in programming is quite different from math at school. In most cases you can see what it’s doing, it is less abstract. Change some numbers and formulas to see how the output of your program changes. Write your calculations down on paper and see what it does step for step. Print out values to test if they are what you expect them to be. This way you will find errors much faster than while staring at your code.

Look up concepts you teacher say you should “know from school”. Don’t remember anything about trigonometry? Look it up on Wikipedia, Wolfram Alpha, Khan Academy or some school book. Let it explain to you by fellow students. Don’t let anyone say you are bad at programming because you were bad at math. It’s just not true.

6. Not caring about your code

You just finished your program and it’s awesome! It does work and has many cool features you didn’t even know you could implement some days ago.

a heartCongratulations! But don’t stop here. Take you some time to care about your code. Write comments so you know what you’ve done and why when you open it up the next time (which might be in some months). Delete lines you don’t need any more. Make sure you code looks nice: Structure it into meaningful blocks, check your indentation and the position of you brackets, delete unnecessary empty lines. Rename variables and function names so the names reflect their function. Describe what the program does and how to use it in a readme file or inside a comment at the top of your program. Rename files so will find them again when you’re searching for them in a couple of month. Make a backup.

This sounds like lot of unnecessary work but your future self will thank you. You will get better at writing clean code with every program you write. If you are unsure on how to care about your code, read code by other people. Open source projects are a good starting point. Look how other people write their code and adapt their style.

« »

© 2018 Miracula's Blog. Theme by Anders Norén.