25 June 2016

What is really BAD about bad code

WHAT is BAD code?

In programming we all come across GOOD code and BAD code. CODE will be BAD if it has the below traits:

  • Long methods and longs classes doing more than one thing. Violation of SRP principle.
  • Lot of nested if-else loops
  • Repeated code all across the project code base.
  • Not using the best algorithm for the purpose.
  • When migrated to latest framework not using latest features (which are usually more optimal)
  • Not enough comments to explain WHY the code is something on WHAT it is doing.
  • etc, etc… (so let’s stop here.)

WHAT is really BAD about bad code?

As knowledge of the developers working on the project improves and also with latest frameworks released, what was looking GOOD code a few months back will start to appear as BAD code or not so GOOD code.

So as Developers we are used to start using our improved programming knowledge and domain knowledge to write any new piece of code.

But we are bit hesitant to touch any existing code to improvise it.

If we keep such existing bad code longer in the project code base, I think the new developers joined the project or the junior developer in the team tend to repeat that code even while developing new business functionality.

So BAD code is getting repeated even more with time.

Now let’s justify the blog post title, “What is really BAD about bad code”.

I think as a developers in the team if we don’t take time out to replace the bad code in the project code base, that is really bad about the bad code.

Approach to remove bad code

The easy solution to replace such bad code is to make steady progress every day to improve one small piece of code, test it and check in. If all the developers get into this momentum the code will keep improving and always it will remain GOOD code.

No comments:

Post a Comment