Tips for beginner programming mistakes
Fear and lack of self-confidence
The number one mistake you can make as a beginner programmer is to think you’re not good enough, not smart enough: that you have the wrong type of brain, and you’ll just never get it. I believe that anyone can learn to program to at least a basic level, if they stick with it.I’d advise any beginner programmer to play with the drag-and-drop visual programming tool Scratch. It’s a brilliant way to learn programming concepts like loops, “if” conditionals, variables and arrays, without being put off by mistyping code. Because there’s no typing! It’s increasingly being used in schools to introduce programming, and I can’t recommend it highly enough.
One way an experienced programmer can almost instantly spot code written by a beginner is messy formatting, such as not indenting code properly or having inconsistent use of new lines and white space. Indenting code is one of the ways we show its logical structure. By tabbing or spacing code in from the edge of the window, we show where functions, loops and conditionals start and end, so we can be sure all our code is in the right place. There are various conventions for how to format your code, and it doesn’t really matter which you use as long as you are consistent. Another bad habit is leaving big chunks of commented-out code that you don’t need any more, but you’re keeping there “just in case”. We all do this, but every day or so it’s good to take a skim over the code and delete any commented-out sections – you’re not going to need them again!
Use of uppercase and lower case
Bad variable and function names
The worst variable naming is to have a spelling mistake in a variable name. It’s hard enough to remember your variable names without having to remember which spelling mistake you made. Another common bad habit is making slang variable names.
Commenting! Commenting! Commenting!
I’m a big fan of self-documenting code – that’s code where the variable, function and class names, and overall architecture communicate the meaning of the code to other developers (and your future self!) without the need for lengthy comments. However, I do also see the value of commenting, especially where it flags a work-around for a specific issue that might not be obvious.What you don’t need to do, however, is write comments like this: “score += 5; // adds 5 onto the score”. What you would be doing there isn’t documenting your own code, but explaining how programming works. This might be a useful exercise when writing your first program, but it’s not something you should hang on to.
Not knowing the full expressive power of programming language
it’s really time to start learning some of the less common operators – they’re incredibly useful. For example, here are some to swat up on:
! – The not operator, represented by an exclamation mark, reverses the value of a Boolean.
% – Called modulo, the % operator is nothing to do with percentages.
The ternary operator, represented by a “?” and a “:” allows you to perform a conditional and an assignment in a single line
Languages, Frameworks, Platforms and IDEs
When starting to learn programming, especially web programming, you’re bombarded with different languages, framework and IDEs, and it can be very hard to know what they all are, so let’s quickly settle some of the common misconceptions.
Firstly, without wanting to be too pedantic, HTML and CSS aren’t programming languages. HTML is a mark-up language and CSS is a styling language. They’re great skills to have, but when you’re writing HTML and CSS, you’re not technically programming.
If you’re working in a statically typed language like Java, C# or ActionScript3, you should be using the debugger. These languages give you really detailed errors, which combined with a debugger, can help you track down the bugs in your code easily.
Back-up your works regularly
There are so many good tools for automatic back-up and version control now, that there’s really no excuse to lose anything, even if you have a major computer malfunction, fire, burglary or other minor disaster.I work from my Dropbox folder, which automatically backs up my all my files, with version history – and when working with other developers or on open source projects, I also check my code into an SVN repository or Github. All these tools have free-to-use options.