5 Bad Habits to Avoid to Be a Good Programmer

  • 2021-07-06 10:39:55
  • OfStack

When you start to be a programmer, it is easy to fall into the following bad habits when programming.

As a programmer, making mistakes is inevitable. This is part of your programming course. You will make many mistakes in your career, some special and some common. Through these mistakes, you can learn how to avoid making the same mistakes in the future.

But if you are a beginner, you may make mistakes more frequently than others. So how can we avoid these common mistakes that most programmers make every day?

If you want to avoid mistakes, you must know something about them. That's why I want to share with you a common mistake that hindered our growth in our programmer career.

Before you begin, you may wonder why I know these are mistakes and not the best way.

One simple answer is that I have encountered all these situations in my career. Some situations are often encountered, while others are only encountered a few times. Every time I make a mistake, I regret it.

The worst case is that I don't even know what I'm doing wrong. As soon as I realized that I was doing something wrong, I began to avoid these mistakes. At least, the code I write now is much better than before.

Now you can also avoid these mistakes. First of all, know that what you are doing now is wrong. I know that most programmers don't do anything wrong because they think it's right, so their behavior will adversely affect the program and the career growth of programmers.

Most bad programming habits stem from ignorance, and there is no other reason.

To be a good programmer, we must get rid of these ignorances one by one. This is what good programming books try to show us.

Part of the reason why we make these mistakes is that they do finish the work. It's not what we have to do to get our programs running and finish our daily work.

But making what works is only part of your job. If you want your application to work, you will have to update regularly and fix any new bug, which will probably become very frequent. One way to make your job easier is to follow good programming practices.

In addition, even if you can get rid of these errors in small programs, you may encounter them in large programs.

If you continue to make these mistakes, your program may still work properly and perform the required tasks, but it will become easy to produce bug, full of inefficient code and difficult to maintain. And, when you look at the code after a long time, you will find it difficult to understand.

As programmers, our job is not just to make our programs work, but to let users handle bug. Our job is to ensure that users will not get unexpected results even if they make mistakes.

So to create high-quality applications, make sure you don't make the following common mistakes when programming:

Copy code without understanding

You will often find that the code you need is found in 1 other program. It's tempting to copy the whole code and just use it without worrying about understanding every 1 line of code.

Sometimes the code you copy may be too big to fully understand. If you copy any code like this, there is a risk that your program will become vulnerable to bug and so on.

This may get the job done, but what if this code produces some unexpected behavior under certain circumstances? What will happen if you slow down your program or have malicious behavior? Therefore, you need to understand the code properly, or you need to be absolutely sure of the source of the code you copied.

If bug is generated later, you will find it difficult to understand the code because you have never written it. You may even find it difficult to find bug and fix it, especially if you copy a lot of code in different parts of the program.

So be careful when copying code, even if there is very little code. Make sure you fully understand it. If you've used a piece of code before and you're 100 percent sure it works, then it's safe and usable. But if not, be careful.

Start from scratch every time

This is the opposite of what I said before, but it is another mistake that beginners are prone to make.

Maybe you think it's good to start from scratch every time, but in fact it wastes too much resources, time, energy and thinking, and you can better use them in other ways.

If what you need already exists, use them. Don't repeat the most basic things over and over again.

You can use this time to make your application better in other aspects.

If an API, framework, or game engine makes your task easier, there's no reason not to use them. Your goal is not to show how good you are, nor to prove that you can accomplish any task on your own. Your goal is to ensure that your applications work perfectly and spend as little as possible to create them.

If you do this, you can finish the same work in less time. Time is money. Even if you work for yourself, you should try to make more money in the same time.

Start Google without trying it yourself

Many times, out of habit, every time a new problem arises, you will look for a solution through Google. This is not a good way for programs. If you always search for answers through external methods without trying yourself, your thinking will never be challenged.

When your mind stops challenging, your own programming skills will stop growing. If you practice any of your own skills well, you can solve problems by yourself, which also applies to program development.

You are creating something that already exists, and you never create it. Is this really what you want to do?

Searching for existing solutions may seem clever, but it will blind you and your laziness will prevent you from becoming a good programmer. If you really want to search for a solution, at least, at the beginning, you should spend 1 point thinking on this problem.

Maybe you can solve it without much incident yourself. Maybe you will have a better solution to it than others. Maybe your solution is more precise than others.

If you don't try, you'll never know.

Ignore warnings

This is another mistake I made in the early stage of program development. I can't tell you the difference between a few hundred alerts in your program and none at all-the most important thing is to ignore it and create new problems.

A warning is usually a sign that something you do may not work properly every time. Sometimes, ignoring these warnings can cause great security problems. But the real problem usually occurs when a program has hundreds of warnings, or when the program doesn't work properly.

It is difficult to determine exactly what caused the error, and you must spend more time analyzing every warning to find out the root cause of the problem. On the contrary, you can dispose of the warning when it happens.

Usually you just need to use the right variables or the right functions to handle these warnings. It won't take you hours, it only takes you a few minutes to meet them and get rid of them.

Handle warnings as early as possible. Clean code looks comfortable and works high. Remember-treat warnings as well as errors.

Quick repair instead of permanent solution

Yes, I feel guilty about doing so. I'm not proud of it. But usually, we just fix it hastily, and rarely solve this problem fundamentally.

It works properly and the problem is solved. But if you are not careful, the problem will reappear in different ways.

No matter how you fix a problem, make sure you don't destroy the whole system. Fixes should improve the health of the whole system, not make it slower or heavier.

At the same time, a repair should be able to solve this problem permanently. Long-term, not short-term. Sometimes, due to laziness and ignorance, we usually like to solve problems quickly instead of spending too much time on them. That's why the code we write works well, but it doesn't work in all cases.

If you ignore it at work, you will spend more time later.

Knowing these mistakes can help you avoid them. If you know what you are doing is wrong, you will not do it in general.

In order to do a good job, you should love what you do. If, for some reason, you don't like programming, you will hardly spend the extra effort to write a good maintainable program.

If you are going to write a good program, you should change your view of programming.

You should think of programming as an art and you are an artist. Then you won't make mistakes because of laziness and carelessness.

Will a writer publish an unfinished article? Will painters sell unfinished paintings? Will a singer sing useless lyrics in his songs?

Never.

It's the same for programming. Under no circumstances should you write untested half-baked code. Don't publish your program until it is finished. Don't write useless code that you won't use.

These are all common sexual mistakes we make because we like to spend less time at work and do other things. But this won't work. Sooner or later, you will be responsible for ensuring that your code doesn't go wrong.

The sooner you practice the correct programming method, the better it will be for your users and yourself. Sometimes being a good programmer means that you don't make the same mistakes as bad programmers.

Thank you for reading. If you know anyone who doesn't know these programming skills, please send this article to them so that they can become good programmers.


Related articles: