Why writing clean code makes you master at your craft?
Learn the cost of not writing clean code
Have you ever wondered what’s the fuss about clean code?
Have you ever thought why in the first place you need to write clean code?
Isn’t writing code that meets the requirement sufficient?
Here are 7 reasons why clean code matters.
Your code is written once but read hundreds of time
Other developers and even you will read the piece of code you wrote at least about 100 times in the next year.
So if you have written spaghetti code, you and other fellow developers would have to rack your brain every time that piece of code needs change or issues.
Clean code begets clean code. Spaghetti code begets spaghetti code
Here’s the thing.
What you write becomes how things work for the product. All the changes that follow will be built on what you wrote.
So you might have only written once. But it stays in the product sometimes for years.
What that means is some of the junior engineers will follow that pattern and that means more spaghetti code if it started with spaghetti code.
Hidden Bugs
Spaghetti code is hard to read and understand.
Bugs will stay hidden in that code for years as most developers wouldn’t understand what’s happening and they will never touch it unless there is no other way.
Sometimes, you might even not know that users are having a bad experience because of those hidden bugs.
Spaghetti code is expensive.
Following the last point, the spaghetti code is hard to change. Requirements change often but the code becomes harder and harder to change.
It means large development times and larger testing times.
Organizations then try to expand testing teams, create automation scripts, and spend time identifying regression suits and whatnot.
But, the core issue is the code and design of the system.
Spaghetti code is unsatisfying
As developers, you love the thrill of creating new stuff and being the master of craft. But writing spaghetti code denies you that satisfaction.
You know there are bugs and there are issues that might crop up.
You know it is not the perfect job you have done.
You want to be the artist who is not satisfied because of blemish even if nobody could see.
Marketability
If you are a developer looking for a job, you have to showcase your coding skills by creating some projects.
But if you write spaghetti code, interviewers will reject you outright as they can see that this would be someone who would need to be taught to write code.
The sad part is they would not give you that feedback and also all the effort you put in to make the project is actually stopping you from getting the job.
What happens when you write clean code
The process of writing clean code takes time. You will find that you take longer to write clean code than the first best version.
But the effort that you put in makes you a better developer.
You learn new design patterns
You get better at following DRY principle
You focus on making the code readable and thus help your own future self
Your peers appreciate the code you write
You feel proud about the code you wrote
Next steps
It is time for you to go and write clean code. If you are unsure, try picking up the book - Clean Code by Robert C. Martin. It will get you started.
I am focussing on writing more articles on Clean code so watch out for those.
If you need urgent help, feel free to reply as I am planning to host a workshop on writing clean code.
📣 Shoutouts of the week
Crash Course on Redis: Excellent article if you are looking to learn Redis
Don’t cross the beams: Kent talks about different types of refactoring. Important to know as writing clean code means you will refactor a lot.
Responsible Tech Guide: Great guide to make sure tech remains for humans