In the previous lesson, you have learned about what is code quality and how it’s essential it is. Now, we are going to differentiate between good code and bad code. Before we are dive into differentiating between code, how do you differentiate the quality of food?
- Good smell?
- Well structured?
- Good appearance?
- Good taste?
- Deliver in the best temperature of food?
What’s well organized can bring you? Well organized is good because you can achieve the same result with lesser effort/cost with a competitive price.
The most developer writing many codes may forget what the code write in the past few weeks. In future, you refer to your code again and again. It’s not just you, anyone who may read your code in future might need. You write code that you barely understand what you write, but you might be unable to comprehend it at all later. Unable to read your code after few months or years later, it’s embarrassing when someone is asking you what’s the code you wrote in the past.
The quality code is clear, concise and straightforward. It has a few characteristics/attributes mentioned below.
Characteristics of Good code
The high-quality code is accessible to read and understandable by anyone even the non-programmer can understand it.
The high-quality code can be easily extended without much-complicated process. Any developer working on the code can quickly make any change. When new developers coming to the team, you may reduce the extra works in long run. It’s always good to keep the technical debt in low.
A good code should always include documentation where it needs. Make sure comments the code where it needs instead of adding unnecessary comment to the code. Writing non-useful comments may cause reversely. The best code is self-documented, you can understand it easily without writing any comments.
The architecture of the overall should be in healthy. Avoid lack of planning or over-structured. Always good to make sure the code formatting is consistent and follow the team guidelines. The code needs to be refactored and make sure in consistent format.
Good code are refactored, reduce unnecessary code and keep it simple using reusable components whenever you can
It’s reusable, you can reuse the code when needs.
You wrote a small piece of software to test the code, make sure it passes all the expected result to ensure the code is bug-free, stable, no crashes, no hangs with all the possibilities.
When anything goes wrong, it throws the issue precisely instead of keeping it silence or do nothing.
There are many security issues are coming due to the bugs and errors in the code. A better code quality are reduce the vulnerable of the software.