Most of us as developers have dealt at some point in our careers with a piece of code that caused us nightmares!
We have all the names and terms to describe it, bad code, garbage code, inconsistent patterns, and so on, let's say here we will stick with the term bad code which will be a general one describes them all.
What is Bad code?
Bad code is simply a piece of code that is hard to change; maybe because of bad abstraction, misleading naming, changed requirements, and responsibilities, or maybe you don't know how to code.
Sometimes we use the term "Readability" but in reality, this term consists of two factors Reader + Writer; this is why I don't consider it as a sign of "Bad Code".
What about good code?
Good Code design is memorable and unambiguous. It encourages readable, correct, and performant code, and helps developers fall into the pit of success.
When you change the way you look at things, the things you look at change. Wayne dyer
You have identified the piece of code you are working with as bad code then what?
The secret is simple:
Don't look at it as this is bad code.
Instead, focus on figuring out what is the issue which is one of the listed above or more, if you find a pattern in it stick to the same design pattern and modify it over time, changing the entire methodology or design pattern especially in big projects takes a lot of time to tweak and handle which most of the times your manager won't accept to give you, and actually as long as you didn't have at least weeks working on this codebase you shouldn't judge it. Try to document the tricky parts you start to have the ability to handle, you will see yourself begin to understand parts of the system you are working on overtime, you can then change the design pattern, but at the same time, global changes take time to be stabilized.
This is my take about bad code.
What is yours?
Let me know in the comments section.
Top comments (0)