The Most Common Coding Mistakes (and How to Avoid Them)

Written by SheepDog | Published 2020/08/13
Tech Story Tags: beginners | tips | how-to | coding | mistakes | codinglife | coding-skills | hackernoon-top-story

TLDR The Most Common Coding Mistakes (and How to Avoid them) The most common mistake beginner programmers make is bad variable naming. Backing up your code is extremely important, even if you are not working on a team. Don’t make functions that take in many inputs, or functions that only accomplish one very specific task. Break up your function into multiple other functions, which are easier to read and maintain. Use the debugger when you run into a code error that you do not know how to solve.via the TL;DR App

There are many mistakes a new programmer can make. Today, you
will learn the most common mistakes that beginners make, and how you can avoid them.

1) Bad variable naming

This is by far the most common mistake beginner programmers make. Name your variables and functions as if your mom was going to have to read and understand what each one means (assuming your mom isn’t a
programmer, of course).
In three months, are you going to remember what the variable you named “
dsld
” means, or what that function you creatively named “
nstnc_crt
” does?
Example of poor variable naming:
Example of consistent variable naming:

2) Not using comments

Comments are an amazing way to remind you what a piece of code does. Too many beginners don’t utilize comments at all, which makes code messy and hard to read. However, there is a fine balance between how many comments you should use in your code.
If you add too many comments, you’ll have to change the comments every time you change the code that it’s describing. It is best to use comments only when a piece of code is not completely self-explanatory.

3) Not keeping code formatting consistent

It doesn’t matter if you put the brackets on the same line as the “
if

statement, or if you name variables with camel case or underlines. Just
make sure you keep it consistent. If you don’t do this, your will code look very amateur, and hard to maintain.

Example of inconsistent code formatting:
Example of more consistent code formatting:

4) Not backing up your project

This is a mistake that could lose you years of your life. Backing up your code is extremely important, even if you are not working on a team. Do not be intimidated by GitHub! They created a great application called GitHub Desktop. GitHub Desktop makes it extremely easy to sync & save your work without even touching the command line. Best of all, it’s free!

5) Using an overly-complicated language

Don’t feel pressured to code in a language that you’re intimidated by just because that’s what many others do, and especially don’t code a custom engine. There are multitudes of easy-to-understand languages that are very beginner-friendly. And, once you know one language, it’s very easy to learn any other language.

6) Not utilizing the debugger

When you run into a code error that you do not know how to solve, don’t
make the mistake of just diving into the code and reading. Use the debugger. Most IDEs have them. With the debugger, it makes solving
issues a breeze; you can watch your code run line-by-line, so you can see exactly what’s going wrong.

7) Creating functions that are too big

Don’t make functions that take in many inputs, or functions that only accomplish one very specific task. Break up your function into multiple other functions, which are easier to read and maintain.

Example of a function which takes in too many inputs:
Example of a function which takes in an appropriate amount of inputs
Hopefully, these tips have helped you out. Have some tips of your own? Let us know in the comments below!
Happy coding! 🙂

Written by SheepDog | For over 6 years, I've been devloping games, websites, and many other technological projects.
Published by HackerNoon on 2020/08/13