Learning to code can be fun and absorbing but it can also be a rocky road at first. If you have a feeling that your learning process could be faster and more efficient, take a look at this list of common programming mistakes. Maybe you’re making some of them?
When I first started learning to code it was a time of constant fire in my belly—I was so excited about every new issue and every new technology! Alright, the enthusiasm was not really constant—it alternated with moments of doubt when I was facing a problem with my code. Sometimes I was learning just for the fun of learning and didn't care much if I was doing it the best possible way. Looking back, I realize that I could have been learning more efficiently, or at least I could have saved myself a lot of worries and stress. After talking to my coding friends I understood that it was not only me, that we've all repeated the same mistakes. Here's a short list of what to avoid in order to have a smooth start in programming.
1. Learning Irregularly
Most novice programmers are so excited about new things they're learning that they use every minute to learn. Enthusiasm burns out quickly, but if you are thinking seriously about a programming career then you can't let it go entirely. And you definitely can't stop learning. What's crucial for learning to code, especially at the beginning, is to learn very regularly. When everything's new it's hard to remember all the information, and regular coding helps to put your knowledge in order. Coding once a week for a few hours is not as efficient as coding every day for one hour. You won't be wasting your time trying to recall syntax or trying to figure out what was your idea for a certain function. Finding an appropriate source to learn from can help you keep to a regular schedule, and online courses, such as these at Vertabelo Academy, allow you to learn at your own pace.
2. Learning Everything at Once
For beginners every new technology is so tempting, they want to learn it immediately. You might have heard about a new framework at a tech meetup, or you might have seen a tutorial of a new programming language on the Internet, and you want to try these out as soon as you can. At least I felt like that at the beginning. As a result, I was endlessly switching between new technologies without gaining any in-depth knowledge. Without solid basics, you won't be able to understand more complex ideas. Some technologies are based on others and won't make any sense separately. Try to resist the temptation and choose wisely the order you will learn new skills in. If you're not sure what the right order is, take a look at the entry requirements while enrolling for a course. For example, if you're a map enthusiast, like me, you'll love the PostGIS course, but to start it you need some basic SQL skills that will be tested in the first exercises. Without SQL, a PostGIS course won't be very useful, and completing it would take much more time.
3. Messy Code Formatting
Disorder in your code can be painful. At the beginning of learning to code, I didn't entirely believe my mentors when they were stressing the importance of tidying code. Sure, I understood it's a good practice but I've paid so much attention to what I was writing, I didn't have time to think about how I was writing it. I understood, however, the very first moment I had to debug my code. Such a simple thing as finding a closing tag in HTML took hours when my code was messy and unindented.
In some languages, such as Python, incorrect indentation will cause errors, and your code won't work. During my first contact with Python, when I was taking my first courses, I used to spend a lot of time double-checking or even rewriting my functions—I was sure they were well written, but they still produced errors. Most often it was the fault not of poorly written conditions or loops but of incorrect indentation.
4. Ignoring Naming Conventions
Your code can be well-formatted but still untidy when it comes to naming conventions. I know it's hard to find good names for your variables, classes, or functions at the beginning. And what are good names actually? First of all, the name must be informative, must tell as precisely as possible what your function is doing. At the same time, the shorter the name the better. It takes some time for naming to become instinctive, but it's worth the effort. You'll make your code a lot more readable, not only for your future self but also for other team members if you're working in a team. Many entry-level courses teach programming with no emphasis on variable and functions names. If you create variables named “a”, “b”, and “c”, it would be good enough for the learning process, but it definitely would not be adequate for a real-life project. If you want to learn the best practices from the very beginning, check out this new Python course in which the authors emphasize appropriate naming conventions.
5. No Backups
They say that there are two types of people in the world, people who make backups and people who will make backups. It applies to backing up both your data and your work. I am sure that all of my friends have lost some part of their work, whether it was code, a chapter of a master's thesis, or an almost finished article. It has happened to me, too.
Fortunately, there is a good solution for backing up your coding work: version control systems like GIT, SVN, and TFS. You can read more about using Git in one of our newest blog posts.
6. Over Complicating
You can easily tell if you're reading a beginner's code—not because it will be that simple, but, on the contrary, it will often be over-engineered. Novice programmers put in a lot of effort to make their code work at all, so they are rarely trying to make it elegant at the same time. In most cases, it's just a side effect of having little experience, but sometimes junior coders want to impress others with the complexity of their work. Unfortunately, such seemingly sophisticated code will give away the author's lack of expertise. There is a principle called KISS that originated in engineering but is quite popular in the programming industry. The acronym stands for “keep it simple, stupid” and it says that simplicity is an advantage (in our case while writing code).
Sometimes overly complicated code is a result of writing without a plan. It's a common mistake of programming beginners because planning a good structure for your work is not an easy task, and it comes with experience.
7. Remorse Because of Googling for Solutions
Have you ever felt guilty for Googling how to do something? Maybe you needed help writing a certain function, or maybe you simply needed to remind yourself of the syntax of a rarely used piece of code? You shouldn't feel bad because it's a very common practice among professional programmers. It's probable that someone already had the same problem that you do and it's already been solved—it helps you save time.
Have you ever heard of Stack Overflow? There are hundreds of thousands of questions and probably millions of answers. This website and many similar ones come to the rescue when you're stuck. Using the expertise of others helps you get your job done. And not only beginners get stuck—it happens to everybody. I've seen each of my coding friends Googling for help or for tips at least once. Not to mention how often I do it myself.
Of course, if you work in a team you can ask someone for help personally, which can be much more efficient (and faster) than reading through many possible solutions on the internet, especially if English isn't your mother tongue. If there's no one you can ask, ask Uncle Google and he'll help. But remember that looking for answers doesn't mean stealing someone else's code. On the other hand, avoid copying and pasting code you don't understand, which is also a very common mistake of junior coders.
8. Copying Code Without Understanding
You've convinced yourself that getting help from the resources available on the Internet is nothing bad, and you're discovering the plenitude of answers at Stack Overflow. Someone had a very similar problem as you and there's a working solution to this. You have no idea what this code is doing but other users said it works, so let's paste it into your project. No, wait. It's not a good idea. If you don't understand how the piece of code is working, avoid pasting it into your project, especially avoid committing it to a working repository without double-checking it yourself and without code review. Even if it solves your problem it may cause errors elsewhere in your application. If you're not sure, ask the author of the code for clarification or talk to your more experienced colleagues to see if this solution is the right one.
How many of these common mistakes have you been making? It can be frustrating at the beginning, but making mistakes makes us better programmers, as long as we make an effort to learn from them. Even though the first steps can be hard, don't give up easily, and keep coding!