It’s easy for developers to make mistakes, but we can prevent them if we know them beforehand.
In this article, we’ll look at mistakes that newbie programmers make that we can all avoid.
Not Using Debugging Tools
Debugging tools are there for a reason. It’s there for us to look at how each step of our program is run and what variables are holding as their value.
We can just do something simple like a console.log
in JavaScript to look at the value of variables in the place that we’re debugging.
Not Backing Up Our Code
Backing up our code is important. We should learn Git so that we can hold our code in both local and remote repositories.
Git is a great version control system, so be sure to commit our code regularly so we can track our changes and revert back code to good code easily.
Assume That We Know Everything
There’s no way that we can know everything or even a small part of a domain.
We all got to keep learning and learn what’s outside of what we’re doing regularly.
This way, we’ll know more, be wiser, and can use some of that stuff at work.
We can learn by reading other people’s stuff, tutorials, and may other sources from the Internet.
Assuming Expressions in “if” Need to Contain a Comparison
We definitely don’t need to have a comparison expression in our if
statements.
All we need in most languages is an expression that returns a boolean value.
For instance, in JavaScript, instead of writing:
if (condition === true) {
//...
}
We can just write:
if (condition) {
//...
}
We don’t need to compare boolean variables in if
statements.
Writing Big Functions
Big functions aren’t good. They’re hard to read since they have many things under one umbrella.
Therefore, we should split them up into smaller functions with meaningful names.
Small functions are easy to read and debug.
Also, we should make sure to name them descriptively and make them pure functions whenever possible.
Pure functions are good since they always return the same output for the same sets of inputs.
Also, they don’t commit side effects. Side effects are actions that take place outside of a function.
Half Baked Knowledge
Usually, newbies don’t know everything completely, which is normal. Unless we go learn the rest of the domain ourselves, we aren’t going to be learning everything completely.
We can’t depend on people to tell us to learn, so we’ve to go learn them ourselves.
It’ll make us more useful inside and outside of work.
Forget About Pen and Paper
We got to write stuff down sometimes so we can break down hard and complex problems.
Problem requirements and limitations got to be understood and we might have to break them down on paper.
Data structures problems are also better solved on paper.
We may also write down all the cases of a problem to make sure that we didn’t miss any edge cases.
And pseudocode always helps us with outlining the code that we’re going to write.
So we should use a pen and paper to solve our issues.
Failing to Get the Basics
The basics are always important. Therefore, we should take into account all the basics and learn them properly.
We definitely should review them so that we don’t forget about them.
Things like algorithm performance and complex are always relevant, for example. We don’t want our code to be too slow.
Also, we shouldn’t catch everything to cover up the errors in our code. Instead, we should write our code properly so that our code is more robust.
This way, users won’t be frustrated with weird behavior, slow performance, or other issues.
Trusting the User with Inputs
Trusting the user too much is definitely a mistake. This is users usually don’t input everything right.
So we should check to see if their inputs are valid. Also, any place that malicious code can get into our system should be checked and whatever we do we should do things like input sanitization from preventing any malicious code from running.
Conclusion
We shouldn’t assume that we know everything. Trusting users to input everything correctly is also a bad assumption.
Also, we should expand our current knowledge and review the basics once in a while so that we won’t forget about them.