crater-invoice / crater

Open Source Invoicing Solution for Individuals & Businesses
https://craterapp.com
GNU Affero General Public License v3.0
7.62k stars 1.53k forks source link

Refactor utilities.js #1251

Open ahmed0saber opened 11 months ago

mohitpanjwani commented 11 months ago

The refactor is good but the current domain check function checks a lot of values and it seems to be working well. Can you explain the reasoning behind updating the implementation for that?

ahmed0saber commented 11 months ago

Hello @mohitpanjwani , the only reason for any refactoring process is to make the code more readable, more cleaner, more maintainable, also there is a rule in refactoring which discusses not changing the functionality of code during code refactor, so I'm not fixing a bug, error or anything, also I'm not adding a feature, but I'm just trying to write the same functionality in a better way, so it's easy to understand it and maintain it in the future. The first code (before refactoring) may take 1 hour to be understood then maintained if any problem occurred there, but the second one (after refactoring) may take about 10 minutes or less, so refactoring code can save us time, and cost depends on time, so we can also save some money or invest this time to do something else that may have much urgent priorities.