What is refactoring

Refactoring
  • A disciplined technique for restructuring an existing body of code
  • altering its internal structure without changing its external behaviour
  • Small restructuring, so it’s less likely to go wrong
  • Make code neat so it’s maintainable and understandable
  • Small, independent learnable techniques to improve the code
  • When you have hammer & drill machine doesn’t mean you can hit anywhere and drill anywhere. It needs to be systematic, balanced.
  • There are around 300 formal refactoring technique

What is not refactoring

  • Code refactoring is not optimisation nor performance improvement. Code Optimization & Code Refactoring are discrete
  • We may end up making code faster or slower
  • Remember: We are making a strong house, the cost is going to increase as compared to building a house faster
  • It’s not intended to make the system faster; but ourselves faster as we can read, maintain, scale and fix the code faster. Adding features becomes very easy if the code is clean. In refactoring we don’t add features, we don’t change the observable behaviour of the application

Why we should refactor

  • You can’t write perfect code in one sitting – Impossible
  • Remove future roadblocks. Avoid future bugs.
  • It’s not like the polishing underside of the table which is never visible. It always has a purpose
  • New joiner: he can start working immediately if our code is readable
  • Code is scalable, pluggable and detachable
  • Refactoring adds small risk and we will discuss how to reduce this risk in future posts