If The Code Works, Don't Touch It !

zairiaimendev

Aimen Zairi

Posted on November 3, 2021

If The Code Works, Don't Touch It !

This is a repost with little modifications of a post originally in my blog.
zairiaimen.com
If you don't want to read the post, you can also watch the video version of it :

The sentence โ€œif the code works, donโ€™t fix itโ€ is sometimes taken as a rule by newbie developers. Though most of the times it works, i Personally think it is just an excuse from lazy developers.
What is even a bigger problem are people who learn frameworks without learning the basic concepts which causes them to write spaghetti code, and when they see this "Rule" they think it's something everyone does.

Why You Should Fix Your/The Code

  • Becomes more readable by other
  • Improve the code
  • having testable
  • having extensible code

When To Not Touch The Code

  • New To The Job
  • Not Experienced Enough With The Technology
  • A Part Of the Code That Won't Change Over Time
  • Usage Of Open/Close Principle ( Add New Features Without Removing The old Ones )

How To Fix

  • Read The Code Multiple Times Until You Understand It ( We All Know that our old code can only be understood by GOD but still give it a try )
  • Separate Logic From State / UI Management
  • Use Design Pattern To Turn The Logic Into Small Testable and Extensible Pieces.
๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
zairiaimendev
Aimen Zairi

Posted on November 3, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

ยฉ TheLazy.dev

About