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.
Messy code
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
Some languages are case-sensitive, others are not, but whatever language you’re writing, you should be consistent in how you use uppercase and lowercase characters in your variable and function names. Beginner programmers often create a variable with one case e.g. “var Score = 5”, then later on try to reference it with a different case – “if (score > 3)” – and wonder why their code doesn’t run. Additionally, some programmers move between different languages, bringing the conventions of one language to another, rather than respecting the style conventions of the new language. In JavaScript, function and variable names should use camel case – that’s starting the first word with a lower case letter and each additional word with an uppercase letter, like this: myVariableName, bestScore, winnerName. Other languages might have a convention of separating words with underscores, but when I see that used in JavaScript, it looks odd.
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.
For front-end web programming, the language is JavaScript. Every lesson in the first few weeks of my university course, a student says Java when they mean JavaScript. This is understandable – the name JavaScript is an unfortunate bit of cross-promotion with Java that has caused ripples of confusion for almost two decades now! Another common confusion, when you see $(“#thing”) all over example JavaScript code, is the relationship between JavaScript and jQuery.
Another misconception is to think your HTML, CSS and JavaScript are tied to the IDE you created them in. Unless you’re using something like Dreamweaver templates, whatever IDE you use, your code is just standard plain text that you can open and edit in any other IDE or text editor, even Notepad!
Debugging tools
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.
If you’re working with JavaScript, while you don’t have quite as much debugging power, there’s still more than just “alert()” to help you. Chrome comes preinstalled with invaluable developer tools that let you see your “console.log()” output as well as detailing code errors.
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.
Discover more from CODE t!ps
Subscribe to get the latest posts sent to your email.