As programmers, we will inevitably make mistakes. Even the most accomplished specialists make them. But you’ll become a better programmer faster if you don’t make the same mistakes over and over.
There are many types of mistakes you might make when you’re coding. The majority of them usually come from habits you develop while learning something new.
Fixing these mistakes as soon as you notice them will help you grow exponentially – both in your career and your learning.
In this article, I’ll discuss some of the mistakes you might be making when you’re coding day-to-day – and what you can do to fix them.
Don’t over-engineer your code
The senior engineers on your team will likely advise all the junior engineers to write clean code with better design patterns.
But if you try to add every design pattern into every piece of code you write, your source code will become an over-engineered complex mess that every programmer will be afraid to touch.
Between optimized code and readable code, most experienced coders will prefer the latter. Over-engineered code is so difficult to comprehend and maintain that experienced devs know it will need to be totally redone shortly, even if it is optimized.
To avoid this issue, try to implement clean code using only relevant design patterns.
Don’t fall into the tutorial trap
Tutorials are extremely useful when you’re learning to code. But as developers, our main mission should be to build and ship products (not to complete courses).
Newcomers frequently become disoriented and don’t know where or how to learn new information. Instead, they sit and watch video after video, looking for new stories to tell. This is not the right way to go about learning new things.
The most effective way to watch tutorials:
- Make a decision about what you want to build.
- Search for an appropriate tutorial. The most popular videos are often the best.
- With your full attention, watch it from beginning to end.
- Make an attempt to build it yourself.
- Get Stuck! Replay that scene and take a note of it.
- Rebuild the project in your own style once it’s finished.
If you follow these steps, the actual experience of building the project will teach you so much more than just watching or reading a tutorial.
The freeCodeCamp YouTube channel has lots of interactive and project-focused tutorials on a wide range of subjects. You can check them out and follow the above tips to get the most out of them.
Don’t just copy and paste code without understanding it
Many developers Google for answers and then just copy and paste someone else’s code into their own. This technique can really help speed up your work and teach you a lot about programming – if you use it correctly.
Still, reading, understanding, and writing the code yourself and in your own style will help you learn things faster and more effectively. Creating something yourself cements it in your brain much more than copying/pasting without analyzing what’s going on.
This will effect your productivity at the start, but it’ll make you a better developer down the road. So when you can, take the time to learn from others’ code.
For example, say you find this code on the web:
const websites = ["Google", "YouTube", "Freecodecamp"];
In a nutshell, knowing the logic and function of that code will help you stand out from others.
Don’t blindly follow someone else’s strategy
This is a typical error when you’re learning to code. You might be tempted to use the wrong tools because someone else does. But keep in mind that it doesn’t necessarily follow that what works for them will work for you.
As a beginner, you might be hesitant to add to your toolkit. You may be tempted to disregard Git, which you can learn the basics of in a matter of minutes. Or you might use the first code editor you come across, or an out-of-date IDE, instead of doing some research and picking the right one for you.
How to build your own toolkit
Here we’ll discuss how to make your own toolkit that supports your workflow and habits. It isn’t that hard or time consuming if you just work a bit to figure it out.
- Tools can be different according to the project. First you should list what you’re planning to make.
- Look into what other people have said about similar projects. GitHub, YouTube, and forums are a few places where you can find this info.
- These tools are gonna make your life easier. So, you choose wisely from among the options. Try at least 5 – 8 popular tools.
- The most popular one may not be the perfect choice for you. Always choose the one which makes your work productive.
- The process of building a toolkit takes time and experience. Always have patience, your first choice may not be perfect.
Don’t be afraid of code reviews
A code review is a method of providing feedback on someone’s code, particularly in the case of pull requests. You should be open to recommendations and critiques from more experienced developers in your department and receive their advice with humility – but don’t be afraid to ask questions and understand why they requested what they did.
Getting defensive or not being open to feedback from code reviews is a common mistake many new programmers make. Newcomers frequently misinterpret colleagues’ comments as harsh criticism, get mad, and respond with resistance, attempting to prove that they were mistaken.
Code reviews can help you:
- Catch bugs
- Make sure your code is readable and maintainable
- Spread knowledge of the codebase throughout the team
Don’t write poorly formatted code
As a new developer, it’s important to standardize your code with how the rest of your team writes code. Perhaps you haven’t seen how tough it is to navigate other people’s code, so just remember – you don’t write code only for yourself.
Using a formatting plugin is one of the simplest ways to format your code well. Some of the most popular plugins are Prettier for VS Code and Formatter for Sublime Text.
Another tip – naming variables and functions is a very important part of coding, and you should try to name them as accurately and concisely as possible.
For example, something like
user_current_monthly_income appears to be a disaster. But you should avoid using names that are too short. A good variable name for this can be
I recommend using full names with clear meanings that are between 10 and 13 characters long. Large code bases, of course, can have names that are a little more complicated.
The practise of adding short, usually single-line notes throughout your code is known as code commenting. These notes are referred to as “comments.” They explain how your program works and what your goals are.
Commenting might seem simple, but new developers might need to practice to get the hang of it. You might be tempted to add too many comments to explain the obvious, rendering it unreadable. Or you might not use enough, which won’t be helpful to anyone.
Referencing other people’s work is a good technique when you’re commenting your code. Look at similar GitHub projects, read their comments, and learn from them if you’re having trouble understanding how to properly add comments to your code.
- Comments should clear up any confusion, not add to it.
- Comments shouldn’t copy the code.
- Clear code is not exempted by good comments.
- Where external references will be most useful, include links to them.
// http://tools.ietf.org/html/rfc4180 suggests that CSV lines csvStringBuilder.append("rn");
// create a for loop // <-- comment for // start for loop ( // round bracket // newline int // type for declaration i // name for declaration = // assignment operator for declaration 0 // start value for i
Here’s a good guide to help you improve your code comments.
Don’t skip debugging
For any programmer, debugging is an essential and valuable skill. Debugging is the process of locating and repairing flaws in computer programs, software, or systems.
You likely work with languages that are statically typed (variable types are declared explicitly and are thus determined at compile time). As a result, there’s not much to say here besides make sure you debug your code! It’s a good idea to try it shortly after you finish writing your first program.
In a nutshell, modern IDEs all come with great built-in debuggers that have all of the necessary features. You can debug a complete program, a module, a single function, and so on.
You’ll find it helpful to read documentation, watch YouTube tutorials, or simply ask questions on stack overflow, community forums, or of a buddy.
In this guide, we discussed some of the mistakes developers make in their coding journeys. These mistakes won’t make or break your learning, but fixing them as early possible will help you grow a lot faster.
- Don’t over-engineer your code
- Don’t fall into the tutorial trap
- Don’t just copy and paste code without understanding it
- Don’t blindly follow someone else’s strategy
- Don’t be afraid of code reviews
- Don’t write poorly formatted code
- Don’t write unhelpful comments
- Don’t skip debugging
Thanks for stopping by and reading this article. I hope you found something interesting.
If you like my content, you could subscribe to my newsletter and Follow me on Twitter, @Chp_It. I share about computer science, content creation, tech affairs, and learning tips and tricks.
Happy learning! 💻 😄