Bad Code — A deadly nightmare

Manish Demblani
4 min readJul 2, 2017

--

A computer program should be written in a way that not only it works, but it works fast, is efficient and easier to read, understand and modify. When such pieces of code are read by other people, it not only makes things a lot easier for them but also instills a sense of admiration in the reader’s mind about the coder/developer.

“Clean code always looks like it was written by someone who cares.” — Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship

Written above is the general understanding of what is meant by clean (good) code. Bad code is the polar opposite of that. It makes life difficult for everyone, from the reader to the coder/developer.

It was the bad code that brought the company down” says Robert C. Martin, Clean Code: A Handbook of Agile Software Craftsmanship

Cause And Effect

Deadlines and a Code Monkey mindset are the most common reasons for writing bad code.

Many (most) are easily intimidated by the thought of missing the deadline. A simple thought “What would my senior think, if I miss my deadline” or “I might get fired if I miss my deadline” instills a fear in one’s mind that the deadline needs to be achieved at any cost and to achieve their target, they tend to compromise the quality of code they write.

But the truth is most people (colleagues/managers/co-workers) expect and want a better code. They expect good code in the given time frame and would at times also defend their timelines, schedule, and requirements with passion, but given another thought isn’t this their job.

Then there is another group who write code just to get the job done and ignorant to the fact the way the code is written and how it would affect others. Such a person is usually called a Code Monkey(jugaadu).

Writing bad code can have an adversely affect the way we write code in the future. It could engrave a mentality of one becoming more and more willing to compromise on code quality and keep on writing bad code.

Looking back, each and every one of us when we started to code, would think about always writing the best code that is ever written, but with time due to various reasons, we tend to go loose on the philosophy and start to compromise.

Bad Code is like an endless cycle, at times it might look like a necessary evil and would work but deep down you know that it would come back to haunt you and when it does, it would give you sleepless nights and bad nightmares (if you manage to get some).

Fixes and Solutions:

If deadline is the reason for writing bad code, you should be willing enough to let the other person know the repercussions of writing bad code and how deep the rabbit hole goes. How it could cause hindrances in day-to-day businesses, as in a single line of bad code could bring up a bug that might cause a system failure to an extent that might impact daily business activities.

If the Code Monkey mindset is a problem, you could try making a habit of never compromising the code quality no matter how big the desire to do so. Write good code, even if it means that you offshoot your deadline by a small margin, because deep down your heart you know that it is the right thing to do and would save up a lot of your and others time in the future. Make it a habit of writing clean code, but along with it try to speed up your code writing skills and soon the time would come when you would bear the fruits of your practice; Staying on deadlines along with the ability to write good code and who knows you might even finish it before a deadline.

Remember that time is of the essence, but so is writing good code and maintaining code quality.

Also, when writing code, the thought that the code would eventually need changes to incorporate new features and performance improvements in the future, gives us the right to compromise the quality of code that we write now should never be a primary thought.

Summing it up

When writing code, always keep the following thought in your mind.

Treat the code you write as your own child, the way you would think for the betterment of your child, and the care they would receive from you, make sure that you give the same amount of care and love to the code that you write as well.

Clean Code till the end!!!

Found this post useful? Kindly tap the ❤ button below! Feedback and Comments are appreciated.

--

--

Manish Demblani
Manish Demblani

Written by Manish Demblani

Archduke of Computer Engineering. Code to enjoy, like to build stuff, software architecture, DevOps, and learn new technologies. LFC Fan #YNWA.

Responses (1)

Write a response