Over a million developers have joined DZone.

10 Mistakes Beginner Programmers Make

DZone's Guide to

10 Mistakes Beginner Programmers Make

For all the novice coders out there, get ahead with this article that lists the ten most frequently made beginner errors.

· Agile Zone ·
Free Resource

[Latest Guide] Ship faster because you know more, not because you are rushing. Get actionable insights from 7 million commits and 85,000+ software engineers, to increase your team's velocity. Brought to you in partnership with GitPrime.

We all have gone through tough times as a beginner, and if you are starting your coding journey, then you can relate easily. Coding is not easy, and beginners are prone to make mistakes. That’s why today I will list ten mistakes beginner programmer makes. By knowing your mistakes can help you improve as a programmer.

To help the reader, let's go through the mistakes and their possible solutions.

During my experience as a beginner (I still consider myself as a beginner), I saw some patterns and regular frustration that keep repeating from time to time.

For helping my readers, I have decided to list the ten mistakes beginner programmers make. After reading the list, you can easily decide for yourself on which mistakes that need to focus on and solve them one by one.

1. The Know-It-All Attitude

We are humans, and we are fragile. And, that’s why we try to overestimate our ability and knowledge.

All of us have gone through this period. Coding is fun at the start, as you will get a lot of resources to fiddle with. This leads to a pleasant start where you explore the possibilities without much challenge.

The internet is friendly to a beginner, and hence the first few sessions with coding will be extremely pleasurable and less frustrating, leading to “The Know-It-All Attitude.” This attitude can make you go slow on your learning path. To ensure that you get rid of the attitude, you should explore more. The first thing you can do is explore complex projects on GitHub and understand how much knowledge and effort it takes to build a decent project.

Taking to peers about their experiences can also help you to understand the learning curve programmers need to go through when they start out.

I am not against "feeling good" when you start your journey, but keeping your feet on the ground is the best way to approach learning anything especially programming.

2. Doubt — Can I Do It?

With “The Know-It-All Attitude”out of the way, there is another reason why beginners slow their learning process.

The killer this time is doubt. Programming is never easy and when coupled with doubt can lead to disaster. This can make the journey short-lived, or the learner can easily conclude that they are not capable of learning programming.

Doubt never works the way we intend to; only courage can solve problems. Computer science is the field of solving problems and if you start doubting yourself, then how can you solve problems for a computer (analogous to helping others, to love or help others we first need to help and love ourselves)?

The best way to overcome the doubt syndrome is to get community help and seek friends that are at same level as yours. Watch inspirational movies and leap of faith. Always remember, failure is the first step to success.

Failure is the first step to success.

3. Non-Consistent Code Writing Style — A to 3 and Bingo

Writing non-consistent code is natural for beginners. A beginner should always aim to write code that is well-structured, have a proper indentation, have CamelCase notation for variable names, proper commenting and so on.

Beginners are always prone to using the small case and large case variable names randomly, all over the code. The notion of consistent code writing style is important and always makes it easy for anyone else who will look at the code later on or maintain it.

Also, maintaining consistency can improve productivity. It is always advisable to write using an IDE or a text editor to make sure that variable names are automated after the first declaration.

Always remember, we always write code for other humans and not the machine. Maintenance engineers or coders will read every code that you will write in your life and they will find the consistency helpful.

4. Bigger Functions are Better — Not!

Complexity makes us believe that we are intelligent, crazy and different from others. Though complexity can be quite rewarding for many, according to Einstien, it is always better to find a simple approach.

This leads beginners to write bigger functions that can consist of hundreds of lines. The biggers functions are hard to debug and maintain, and this can lead to unfavorable situations such as spending the whole night finding and fixing bugs.

The solution? Break it into small and readable functions. No one hates readability, and you will also find it easier to debug the whole code (which for mysterious reasons, doesn’t compile without error on the first try).

A great analogy that I can provide is “Writing in natural languages.” In this case, English. If I start writing the whole article and do not split the content into the paragraphs, it will be tough to read and understand.

Simplicity easily wins over complexity and its always better to write a code that is easy to debug and maintain shortly.

5. Bad Function and Variable Names: In Short, Write for Humans

With functions in the discussion, it is quite natural for me to follow the same line of thinking. Functions are great; they are used to create a block of logic and then can be used in large to create useful programs or apps.

But, functions looks great and feels better if their names are meaningful.

For example,

DoesXThing() {}

The idea is to tell you and the future maintenance engineers what your functions are going to do. And, yes that doesn’t mean you are going to write a function name 100 words long.

A function name,  ToCalculateTheMeanOfTheSumOfEpicNumbers() is useless. It confuses others and you, too, in the longer run.

A better function name would be  MeanSum().

Now, comes the turn of variable names. Variables names and function names are limited by the programming language you are using. Many programming languages doesn’t let you start the variable or function name by an underscore (_) or number.

On the other hand, variable names should always be short and easy to read.

Recently, I have been active on HackerRank and solving some easy problems. I below code is written for solving the service lane problem.

//calulating the largest vechile
def find_vehicle(entrypoint,exitpoint):
    the_final_array = arr[entrypoint:exitpoint+1]
    the_largest = 3
    for each in the_final_array:
        if each < the_largest:
            the_largest = each
    return the_largest

//taking input
length, testcases = input().split()
length, testcases = int(length), int(testcases)

arr = list(map(int,input().split()))

for i in range(0,testcases):
    entrypoint, exitpoint = input().split()
    entrypoint, exitpoint = int(entrypoint), int(exitpoint)
    res = find_vehicle(entrypoint, exitpoint)
    print (res)nd_vehicle(entrypoint, exitpoint)
print (res)

6. Commenting and OverCommenting — Where is the Comment?

A coin has two sides, and this is true for many ideas and concepts or behavior we come across through our daily life.

Commenting your code is necessary and highly rewarding if done right. And, there are two types of people who treat their code rightly. The number one are those who do not comment at all. The other type, do comment but overdo it by a large margin.

Both approaches complement each other. Commenting your code makes it easier to understand and sends the message in natural language to the reader. On the other hand, too much information can make the situation ugly and unnecessarily complicated.

Slight use of humor in comments can work, but unnecessary writing an essay in comments is not at all recommended(unless needed).

For example, Variable += 1 // increment Variable by 1, is unnecessary and unsettling for others.

7. Half Baked Knowledge

Beginners fail to utilize the power of the programming language. The programming language comes with all the tools, and techniques and it is fruitful for the beginner to learn at least one new concept on the daily basis.

Also, mastering a programming language takes time. So, it is always better to stick with the programming language for a longer period. Creating valuable projects can help you gain complete knowledge of the programming language.

8. Backing Up the Work

My friend recently came to my house asking me ways to restore lost work. Of course, there are some ways to restore lost work, but it never a good idea to not backup your work.

Machines are fallible; the hard disk can fail and so does your work. The best way to make sure that your work remains safe is to back up your work at regular intervals.

Dropbox is a great cloud service that can make you save your work in no time. Drag, and drop and it is uploaded to the cloud. And how can I forget GitHub?

9. Not Using Pen and Paper

I am a big fan of pen and paper. The brain works better when I use the tools that I have been using for the past 20 years. The real advantage of using pen and paper is to get you start thinking and solve the problem before writing a single line of code.

Many beginners try to write the code without understanding the problem. That can spell disaster, and they can easily lose time without making any significant progress.

Planning before proceeding is the key here. The basic things that you should keep in mind before starting to write down the code in your editor are as follows:

  • Understand the problem requirements and limitation — The first crucial step is to understand the problem at hand. What’s the input and in which format? What is the desired output? What is the time-limit set for the program? And other tons of question that goes into your head needs to be resolved before moving forward.
  • Data structure to pick — The next biggest step is to pick up a data structure for your problem. Can a stack solve my problem or a list or better a queue? Experiment to find out the best possible data structure for the solution. Picking the best data structure is crucial for the performance of the solution.
  • Think about any corner test cases — Testing your code is as important as writing the code in the first place. Make a Mental map or better write down the corner test cases that you can think of.
  • Think of a rough working draft of your code — This works for me. Not exactly the code that works, but the code that can work and is as close to the solution(Sometimes you can hit bingo on the first try, but chances are less for complex problems).
  • Break the problems into solvable pieces — For many programmers, easy problems can be done in mind, but real-world problems are different and require thorough planning.

Now, fire the editor and start writing code.

10. Not Using Proper Debugging Tool or IDE

Debugging is an essential part of programming. Debugging can be done manually or using a tool. The tool provides vital information regarding the errors or bugs that make the program not usable.

Using debugging tools or Integrated Development Environment(IDE) can improve the way you write and debug code, improving productivity and satisfaction.

Wrap Up

Programming is one of the rewarding trade out there. It can be frustration on many occasions, but many of us know the rewards and satisfaction it yields after successful execution. Today, I went through the ten mistakes beginners programmers makes.

The list is in no way complete, and the readers are encouraged to share their own experience. Beginners experience the world of programming differently and it is always best to make mistakes as fast as you can. Understanding that you are making mistakes fast can improve you in less time and make you a better programmer in a long run.

The idea of this post came into my mind when my friend asked me on how he can avoid making common mistakes. It’s very easy for beginners to fall into the trap of thinking that they are moving in the right direction and can lose precious time practicing odd habits and code writing habits.

So, do you think that the article is complete? Comment below and let us know. Also, do not forget to tag your friends and share it with them. Share the love!

The article was first posted on TechAltair.

[Latest Guide] Ship faster because you know more, not because you are rushing. Get actionable insights from 7 million commits and 85,000+ software engineers, to increase your team's velocity. Brought to you in partnership with GitPrime.

programming ,mistakes ,beginner ,novice programmer ,agile

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}