A few weeks ago, I came across this image above and because of that I’ve decided to write this post, showing the importance of writing a good code.
What does “a good code” mean?
I think the variables may change slightly depending on the language we are using, but there are some general rules that apply to all languages.
There are some points:
- When you have to add or modify a feature, is it too difficult?
- Do you constantly break existing functionality when making changes?
- Is it hard to understand some code that you are seeing for the first time?
If you’ve answered “yes”, you need to start reviewing your code.
Why to write a “good code”?
Doesn’t matter if we are talking about client side or server side. The consequences of writing a bad code can be terrible for the developer himself.
“What is my code doing?”
This question seems to be crazy, but I am sure that you have already asked yourself.
“It is just a text field, should be easier to implement”
Yes, sometimes an easy thing can become a problem or take a long time to implement.
“I just modified that and nothing else works.”
Functions and code blocks should be well defined and isolated, so you would not destroy the whole system when editing a single line.
How to write a “good code”?
- Plan Before You Write
- Commenting & Documentation
- Good Indentation
- Avoid Deep Nesting
- Consistent Variable Names
- Code Refactoring
If you do not know some concept above, please just google it. I’ve listed a few important ones, but there are a lot more.
Try to challenge yourself in writing a better code. Ask for help from a more experienced developer on how you could improve your code. And the most important, before writing the code, think about the best way to do it, even if it takes a few precious minutes, I’m sure it will be worth it.