7 Reasons Why You Should Write at Least Clean Enough Code 1


You have probably heard that you should always write and deliver clean code. Although that would be ideal, it does not always happen in the real world. There are many variables that prevent writing perfectly clean code. As a result, much of the code that you will encounter is “clean enough” with some lousy code on the side.

Over the years that I have been developing software professionally, I have gone from writing lousy code to “clean enough” code. When I graduated from college, I was a lousy programmer. I did not know about writing clean code. I would copy and paste, choose poor variable names, have functions doing more than one thing, mismatching indents, and more. These bad habits made it difficult for any of my projects (work or side) to be manageable after a while.

 

Naturally, I knew I needed to change my bad habits in order for me to improve my skills in software development. I began researching about writing better code and began to put those techniques into practice, eventually making them a habit. I was able to write clean and readable code for what I already knew. Code that involves learning something new often ends up being “clean enough” code, where it is readable but not always nicely structured. I am always learning something new for my projects, so I always end up with “clean enough” code, but the value that “clean enough” code provides is tremendous.

 

My goal in this post is to share with you what I noticed going from lousy code to “clean enough” code. To be more precise, six reasons why you should be writing at least “clean enough” code.

 

What Is Clean Code?

Clean code is a technique that focuses on the reader to produce software that is easy to read, write, and maintain. Often times, developers consider their work complete when the code does what it is supposed to do. What they forget to account for is that humans are going to be looking at their code. If their code is not understandable to the human readers then that is a problem.

 

Write Clean Code for Yourself

The code you write might not look the same to you a few months later. It seems to make perfect sense at the time you wrote it, but after a few projects and you revisit the code again you are lost. It may sound silly to get lost in the code that you wrote yourself, but it does happen when you write lousy code. When that happens, you need to put your time and effort to figure out your own code. If you had written “clean enough” code at the start, you would have saved yourself a lot of time.

 

Write Clean Code for Your Team

You will rarely find yourself working on a project on your own. If your team members cannot understand the logic of your code by reading it, then there is a problem. Other developers might be extending your code or developing something to work with your code. If they are misunderstanding what your code is doing, it can lead to undesired results. The same case can be applied to yourself.

 

Foundational

Writing clean code is a foundational skill that pays off. It helps speed up development because it produces code that is easy to read, write, maintain, and extend. In addition, the benefits of clean code shine when it comes time to refactor or test. Since clean code is modular, it is easier to read and to test.

 

Justify Your Techniques

Writing clean code is not something you can do without practice. Some developers cannot write clean code no matter how hard they try. Sometimes, clean code is a metric to determine how skillful a software developer is. When you write clean code, you are able to convey concrete activities, patterns, and techniques. Therefore, the ability to write clean code is highly desirable.

 

Easier to Maintain and Extend

If your code does not follow a pattern then you might find it difficult to add a new module or make changes to a current module after a few months. You will have difficulty figuring out what will be affected from making changes. For example, if you need to add a new property to student profiles, it would be easy if you represent a student as a class. All you have to do is add the property in the student class and every student profile will have the new property.

 

Easier to Debug

After deployment of a project you worked on, you start receiving feedbacks that feature A does not work. It crashes continuously and never runs for longer than a few minutes. If you separated the feature with its own classes and or methods then you can debug the issue step-by-step. However, if you have written the feature in one gigantic file cluster with other features you will not be having a good time.

 

You Are Lazy

The word “lazy” here means going to great effort to reduce overall energy expenditure. As software developers that tend to be how we think. If we need to do something repeatedly, we end up thinking about how we can automate the process. Maybe write labor-saving programs and provide documents that you wrote that people would find useful. The same principle applies to writing clean code; you should do it because it will reduce the number of development cycles for projects.


 

I hope you found this post helpful. If you found this post helpful, share it with others so they can benefit too.

 

What are some of your experiences with lousy and clean code? How do you incorporate clean code into your projects?

 

Leave a comment or send me an email at steven@brightdevelopers.com. To stay in touch, follow me on Twitter.


About Steven To

Steven To is a software developer that specializes in mobile development with a background in computer engineering. Beyond his passion for software development, he also has an interest in Virtual Reality, Augmented Reality, Artificial Intelligence, Personal Development, and Personal Finance. If he is not writing software, then he is out learning something new.

One thought on “7 Reasons Why You Should Write at Least Clean Enough Code

Comments are closed.