How to write clean code?
Prashant Maurya
Co-Founder & CEO at Spheron Network | Scaling Startups, Simplifying Success
I have met many people from different domain in IT industry working together to solve a problem. I have seen product going into production with many bugs into it which is very obvious but there are times when we have to solve some critical bugs at a rapid pace. In such cases speed with which developer is going to solve a bug depends how other developer has written a piece of code.
There are developers who write more lines in order to make sure while reading the code another developer can understand easily and there are many developers who will write less line which no one can understand easily.
Reason behind writing this small article is to present some benefit of writing clean code and thought process requires to write
Benefits Of Writing Clean Code:
- Readability: Code written in a clean way will result in faster understanding and onboarding new people into the project
- Maintainability: Maintainability of code base and product quality is more costly than developing product from the scratch.
- Testability: Code written in a clean way is more easy to test than the complex code
- Bug Fix Time: Clean code will help developer to debug the issue more faster than the complex code.
Thought Process Requires:
Few thing one has to keep in mind while writing code:
- Follow KISS principle (Keep It Simple And Stupid)
- Follow DRY strictly (Don't repeat yourself)
- Follow SOLID principles if you are writing code in OOP(Object Oriented Programming)
- Avoid being lazy while writing code
Conclusion:
It’s not easy to start writing clean code in a day it requires days of practice and effort but the day you will learn, you will love it.