Why Is It So Easy to Become a Bad Coder?

I was once a really bad coder and at that moment…

Jason In
Jason In
Mar 16 · 3 min read

I was once a really bad coder and at that moment, I had no idea what I was actually doing — that I was writing bad code. Well, trust me, I have been through all these.

I remember a few years ago Bill Gates shared this

Anybody can learn to code. And everyone should give it a try — Bill Gates

and also Steve Jobs once said

Everybody in this country should learn to program a computer, because it teaches you how to think — Steve Jobs


People have been talking about coding, writing programs or websites all the time. Coding Bootcamps and online coding platforms are everywhere. Unlike twenty years ago, everyone can easily learn how to code a “Hello World” program in less than 5 minutes in almost any language.

Many people like to claim that they can code in a language after running their first “Hello World” program. However, there are much more people should learn, before they start claiming they know how to code.

Let’s look at the following example:

// Version 1
String[] names = {“Jason”, “Jimmy”, “Jack”, “James”};
for (int i=0; i<4; i++} {
println("Hello" + names[i]);
}
// Version 2
String[] names = {“Jason”, “Jimmy”, “Jack”, “James”};
for (String name : names) {
println("Hello" + name);
}

Can you guys see the difference between these two versions? Although both yield the same results, version 2 is definitely doing a better job.

WHY?

In version 1, every time we add a new element (name) into the array, we have to change the i used in the for-loop. But in version 2, no matter how we modify the elements in the array, the print function doesn’t have to be changed.

An even worse example, I actually did something like this when I was first introduced to coding many years ago:

// Version 3
println(“Jason");
println("Jimmy");
println("Jack");
println("James");
...

See? It is just too easy to write bad code. And interestingly, most of the time, bad code can always function. They are however ugly and could be inefficient and unreadable.

Some people might now ask, so how do I know I’m writing bad code? The fact is that — you do not know. You probably won’t know that your code is terrible until someone tells you.

Code can be clean and elegant, easily readable and scalable. Just like the examples we have above, version 2 > version 1 > version 3. Writing code is easy, but writing elegant code is not.

Writing elegant and clean code is time-consuming but we should always try to do that — Why? Because we want our code to be easily understandable by others. We want others to say “Wow, I like how you write your code! I never knew code can be written in such an elegant way!”


Here are some of my bits of advice to everyone:

  1. READ. There are many books that teach you how to write better code, for instance — Clean Code, The Pragmatic Programmer, Code Complete etc.
  2. READ MORE. Learn what Big O notation is and how design patterns can help us in writing code that is scalable
  3. Code reviews. Ask people around you (Of course to those who know how to code) to try reading your code and discuss with them if there is a better way of writing the code

I’m not saying that whoever wants to code have to follow what I say, but If you ever want to call yourself a programmer or land a job as a software developer,

PLEASE, LEARN HOW TO WRITE CLEAN CODE

Jason In

Written by

Jason In

Tech Enthusiast | Data Scientist | Software Developer | UX Designer

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade